Enabling editing for bulk published feature services

3258
18
Jump to solution
09-22-2021 01:04 PM
tigerwoulds
Occasional Contributor III

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?

0 Kudos
18 Replies
LongDinh
Occasional Contributor II

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.

tigerwoulds
Occasional Contributor III

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. 

tigerwoulds
Occasional Contributor III

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

 

  • The JSON file is does start with the {
  • I have validated it using an online editor
  • I can copy the JSON from the file and submit it through the MapServer/edit endpoint and it is successful.  Any ideas why I cant POST the JSON file?

 

 

0 Kudos
LongDinh
Occasional Contributor II

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
}
0 Kudos
tigerwoulds
Occasional Contributor III

Yes good catch, I missed that. Unfortunately I still get the same error

0 Kudos
LongDinh
Occasional Contributor II

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. 

0 Kudos
tigerwoulds
Occasional Contributor III

@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. 

LongDinh
Occasional Contributor II

Awesome work! Glad to hear you reached a solution 🙂

0 Kudos
MichaelSnook
Occasional Contributor III

@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!

0 Kudos