I do not have any error messages, however when I check the service, nothing has been added - I am very new to this so please forgive me, if this seems poorly constructed.
Code:
"""
Adds a field to any layer matching the name in all feature services without
republishing
"""
import arcrest
if __name__ == "__main__":
url = "https://services7.arcgis.com/pKZDS1XjUiThltHY/arcgis/rest/admin/services/BuildingsService/FeatureServer"
username = "Name"
password = "Pass"
featureLayerNames = ["BuildingsShapes"]
fieldToAdd = {
"fields" : [
{
"name" : "CommonField3",
"type" : "esriFieldTypeString",
"alias" : "Common Field 2",
"sqlType" : "sqlTypeOther", "length" : 50,
"nullable" : True,
"editable" : True,
"domain" : None,
"defaultValue" : None
} ]
}
sh = arcrest.AGOLTokenSecurityHandler(username, password)
agolServices = arcrest.hostedservice.Services(url, securityHandler=sh)
for service in agolServices.services:
if not service.layers is None:
print service.url
for lyr in service.layers:
print lyr.name
if lyr.name.lower() in featureLayerNames:
print lyr.addToDefinition(fieldToAdd)
# Output: {'success': True}
ArcRest
3.5.9
Version or date of download
Bug or Enhancement
Repo Steps or Enhancement details
I do not have any error messages, however when I check the service, nothing has been added - I am very new to this so please forgive me, if this seems poorly constructed.
Code: """ Adds a field to any layer matching the name in all feature services without republishing """ import arcrest