Created
May 4, 2020 13:36
-
-
Save khibma/e17c30f55b591c26f8557b4a44f64bed to your computer and use it in GitHub Desktop.
Example that uses ArcGIS Python API to authenticate, but uses Requests to make calls to the backend REST service directly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from arcgis.gis import GIS | |
import requests | |
import json | |
USER = "USER" | |
PASS = "PASSWORD" | |
g = GIS("https://www.arcgis.com", USER, PASS) | |
token = g._con.token | |
payload = {"where": "1=1", | |
"f":"json", | |
"token": token} | |
url = "https://services1.arcgis.com/orgID/ArcGIS/rest/services/p5000/FeatureServer/0" | |
p = {**payload, **{"returnCountOnly": "true"}} | |
response = requests.post(url + "/query", data = p) | |
r = json.loads(response.text) | |
print("Count before: {}".format(r)) | |
p = {**payload, **{"async": "false"}} | |
response = requests.post(url + "/truncate", data = p) | |
r = json.loads(response.text) | |
print("Result of delete: {}".format(r)) | |
p = {**payload, **{"returnCountOnly": "true"}} | |
response = requests.post(url + "/query", data = p) | |
r = json.loads(response.text) | |
print("Count after: {}".format(r)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment