Hi All,
I found following link to get ArcGIS server and extension list with their expiry details using REST:
Licenses—ArcGIS REST API: Administer your server | ArcGIS for Developers .
I am working with ArcGIS server 10.4.1 and python 2.7.1(32 bit)
If I navigate to the URL mentioned in documentation, it is not working.
Instead,Corrected URL: http://server:port/arcgis/admin/System/licenses
I want to get the license list using Arcpy and trying to hit same URL but getting 302 as response code.
Is there any constraint on this URL ?just I am trying to use resource listed under 'system' folder? or If I am trying to get license using wrong way?
Thanks for your help!
Regards,
Amruta
Solved! Go to Solution.
This python script may helps you. In my case the arcgis server rest end point is through webadaptor and I have the admin option enabled. If you try to access the rest through port 6443 then you have to configure the certificate on ArcGIS Server because a SSL certificate error will arise.
import requests
import json
print("Start -----")
UserName = '<user name>'
PassWord = '<password>'
### GET A TOKEN
print("Getting token")
token_URL = "https://<domain name>/portal/sharing/generateToken"
token_params = {"username":UserName,"password": PassWord,"referer": "https://<domain name>","f":"json","expiration":60}
r = requests.post(token_URL,token_params)
token_obj= r.json()
token = token_obj["token"]
### SET THE PARAMETERS
print("Creating parameters")
newParams = {'f':'json'}
url='https://<domain name>/server/admin/system/licenses?&token={}'.format(token)
### SEND THE REQUEST
print("Sending request")
r = requests.post(url,newParams)
print(r.json())
print("Script complete")
This python script may helps you. In my case the arcgis server rest end point is through webadaptor and I have the admin option enabled. If you try to access the rest through port 6443 then you have to configure the certificate on ArcGIS Server because a SSL certificate error will arise.
import requests
import json
print("Start -----")
UserName = '<user name>'
PassWord = '<password>'
### GET A TOKEN
print("Getting token")
token_URL = "https://<domain name>/portal/sharing/generateToken"
token_params = {"username":UserName,"password": PassWord,"referer": "https://<domain name>","f":"json","expiration":60}
r = requests.post(token_URL,token_params)
token_obj= r.json()
token = token_obj["token"]
### SET THE PARAMETERS
print("Creating parameters")
newParams = {'f':'json'}
url='https://<domain name>/server/admin/system/licenses?&token={}'.format(token)
### SEND THE REQUEST
print("Sending request")
r = requests.post(url,newParams)
print(r.json())
print("Script complete")
Hi,
Thank you so much for the prompt response. I am able to get the response successfully!
One thing I will check now is response coming in HTML and not JSON and I am not working with requests, but working with 'HttpLib' But thanks Anyway for the code snippet!
Regards,
Amruta
I'm glad the code helped you.