I'm looking at using ArcREST to insert rows in a featureservice on a local ArcGIS Server.

All the sample that I've seen seem to be connecting to a ArcGIS Online.

If I look at the Documentation for the Security Handler Helper module, I can't see where to specify the url of the local server.

Is there a Sample for inserting rows in the featureservice of a local ArcGIS Server?


Here is a sample you could use. I use ArcREST for most of my AGS administration workflows, it's very powerful and imho simple to use.

You will need an AGS feature service and user credentials to create a token.

from arcrest.manageags._services import AGSService
from arcrest.ags.server import Server
from arcrest import AGSTokenSecurityHandler
from arcrest.common.general import Feature

ags_admin_url = r"http://localhost:6080/arcgis/admin"
ags_securityHandler = AGSTokenSecurityHandler(username='user', password='pwd',

base_url =  r"http://localhost:6080/arcgis/rest/services/"
ags_featureservice_service_folder = "MultiuserGdb"
ags_featureservice_name = "FS_Roads"

ags_user_mapservice_with_fs_service_url = base_url + "{0}/{1}/MapServer".format(ags_featureservice_service_folder,

ags_user_featureservice_service_url = base_url + "{0}/{1}/FeatureServer".format(ags_featureservice_service_folder,

rest_server = Server(ags_user_mapservice_with_fs_service_url,

rest_server.currentFolder = ags_featureservice_service_folder
ags_services = rest_server.services

feature_service = [service for service in ags_services
                   if service.url == ags_user_featureservice_service_url][0]

fs_layer = feature_service.layers[0]

features_to_add_to_feature_service = r"C:\GIS\GitProjects\unit_tests_arcrest\GeoData\FeatureServiceInData.gdb\feats_to_add"

features = Feature.fc_to_features(features_to_add_to_feature_service)
result = fs_layer.addFeature(features)
print result

The printed info:

{u'addResults': [{u'success': True, u'objectId': 7514}, {u'success': True, u'objectId': 7515}, {u'success': True, u'objectId': 7516}, {u'success': True, u'objectId': 7517}]}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.