Adding features to feature service layer with stand-alone Python script

06-28-2018 08:35 AM
Occasional Contributor

I am creating a tool that takes records from an Access Database and inserts them into a feature service layer. I'd like this tool to be available as a stand-alone Python script.

I currently have the script working and inserting new features/table records into feature classes in a file geodatabase. However, I would really like for users to be able to run the tool and insert their features/records directly into a feature service.

Is there a particular path I should be using for the feature service layers? How do I deal with this path changing depending on the user? If someone could give me some input on this or direct me to resources where I could get a start on the best way to do this, I'd appreciate it!

0 Kudos
1 Reply
Esri Notable Contributor

An easy way to do it is make an edit in an application like the map viewer and record the traffic using Fiddler. Then, recreate the request using Python. For example, when editing a feature service on sampleserver6, here's the request:





In Python, this would look like:

import urllib, json

url = ''

addsParam = [{"geometry":

requestParams = dict(adds=addsParam,

response = urllib.urlopen(url,urllib.urlencode(requestParams))

Update the geometry, WKID, and then bring in the proper fields from your Access database.