We are running ArcGIS Enterprise 10.8.1. I followed this doc here to bulk publish around 50 feature services: Publish layers in bulk from a user-managed data store—Portal for ArcGIS | Documentation for ArcGIS E...
As the doc states, editing is not enabled by default. Is there a way (either through Portal/Server Manager or using Python) to go into the service properties and enable editing?
Solved! Go to Solution.
I forgot parenthesises in my print statement. It is currently printing the method object and not the returned value. It should be:
print (response.json())
That means the request was successful, however, in ESRI's REST service implementation, the response from the service will return a message in JSON format. You will likely see an error property in the returned JSON.
For other status codes, you can look at this.
It worked like a charm, no errors. Thank you very much!
Next goal is to apply this workflow to over 100 services in a folder on Server Manager so I can make the same edits to every service within that folder. Thank you again for your help thus far.
Hi @LongDinh
For some reason, my script is throwing an error when submitting the POST. I am building the JSON file programmatically (since I have 100's of services), but my code sees the JSON file as invalid.
{'status': 'error', 'messages': ["A JSONObject text must begin with '{' at character 1
Hi @tigerwoulds ,
The variable json_file is a path and not a JSON object hence the input parameter throws a 'does not begin with {' error.
I think your payload on line 100 should be:
payload = {
'f':'json',
'service': service_json,
'token': token
}
Yes good catch, I missed that. Unfortunately I still get the same error
Try converting the service_json to a json string like:
payload = {
'f': 'json',
'service': json.dumps(service_json),
'token': token
}
Hopefully it throws a different error.
@LongDinh unfortunately, same issue BUT I was able to figure this out using a slightly different method from this example. I converted this to python 3 and replaced the httplib/urllib pieces with the functions from the 'request' library for python 3 and everything is worked as expected. Including the payload as you described initially was key to get this working.
I can now loop through a folder on my GIS Server and update properties/capabilities for all services in the folder.
Big thank you for your help again.
Awesome work! Glad to hear you reached a solution 🙂
@tigerwoulds ..I am looking to do the exact same thing but I'm getting a bit lost on the upgrade. Can you share your working Python3 script by chance? Thanks!