Skip to content

Instantly share code, notes, and snippets.

@floptical
Last active November 14, 2019 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save floptical/2c973bd88532376567625703fe915e9c to your computer and use it in GitHub Desktop.
Save floptical/2c973bd88532376567625703fe915e9c to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import requests, json
# Disable warnings
requests.packages.urllib3.disable_warnings()
# Variables
geoeventServer = '12.34.56.78'
username = "siteadmin"
password = "*******"
# Generate Token
#tokenURL = 'https://{0}:6443/arcgis/admin/generateToken/'.format(geoeventServer)
tokenURL = 'https://{0}:6443/arcgis/admin/generateToken/'.format(geoeventServer)
#params = {'f': 'pjson', 'username': username, 'password': password, 'referer': 'https://{0}:6143/geoevent/admin'.format(geoeventServer)}
params = {'f': 'json', 'username': username, 'password': password, 'client': 'requestip', 'ip': '10.8.102.227', 'expiration': '60'}
r = requests.post(tokenURL, data = params, verify=False)
try:
response = json.loads(r.content)
token = response['token']
print(response)
except:
print(r)
# Request URLs
#header = {'Content-Type':'application/json', 'token':token}
#header = {'Content-Type':'application/json', 'access_token':token}
header = {'Content-Type':'application/json', 'GeoEventAuthorization':token}
#theURL = 'https://{}:6143/geoevent/admin/monitoring/geoeventservices/dda0b114-0f25-4013-852d-997b9f09f6df'.format(geoeventServer)
#theURL = 'https://{}:6143/geoevent/admin/monitoring?GeoEventAuthorization={}'.format(geoeventServer, token)
theURL = 'https://{}:6143/geoevent/admin/monitoring/'.format(geoeventServer)
print(theURL)
r = requests.get(theURL, headers=header, verify=False)
try:
response = json.loads(r.content)
print(response)
except:
print(r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment