Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

ArcRest "FieldToAdd" Does Not Appear to be Working? #329

Open
jocktheshockerrr opened this issue Mar 21, 2017 · 0 comments
Open

ArcRest "FieldToAdd" Does Not Appear to be Working? #329

jocktheshockerrr opened this issue Mar 21, 2017 · 0 comments

Comments

@jocktheshockerrr
Copy link

jocktheshockerrr commented Mar 21, 2017

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

 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}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant