Esri / ArcREST

python package for REST API (AGS, AGOL, webmap JSON, etc..)
Apache License 2.0
192 stars 155 forks source link

addAttachment fails #191

Closed larsdevries closed 8 years ago

larsdevries commented 8 years ago

I am using FME / PythonCaller to add attachments to a service. When I call FeatureLayer.addAttachment I get the error message "AttributeError: 'set' object has no attribute 'items' with a reference to following calls:

File "C:\Python27\ArcGIS10.3\lib\site-packages\arcrest\agol\services.py", line 1422, in addAttachment proxy_url=self._proxy_url) File "C:\Python27\ArcGIS10.3\lib\site-packages\arcrest\web_base.py", line 466, in _post files=files) File "C:\Python27\ArcGIS10.3\lib\site-packages\arcrest\web_base.py", line 96, in init for key,v in files.items():

Anyone a clue

achapkowski commented 8 years ago

Can you please post/share your code?
What version of ArcREST are you using?

larsdevries commented 8 years ago

This is the code:

`import arcrest, fmeobjects, fme

Template Class Interface:

class FeatureProcessor(object): def init(self):

PARAMETERS

    username = fme.macroValues['AGO_User']  
    password = fme.macroValues["AGO_Password"]
    LayerUrl = fme.macroValues["AGO_URL"]
    #PARAMETERS###########################
    #generate token#
    global AGOtoken
    AGOtoken = arcrest.security.AGOLTokenSecurityHandler(username, password)
    #generate FeatureLayer#
    global FeatureLayer                                                                 
    FeatureLayer = arcrest.agol.services.FeatureLayer(LayerUrl, AGOtoken)                  

    #check FeatureLayer properties#
    if FeatureLayer.canModifyLayer == False:                                            
        print "Error: layer not editable"
    if FeatureLayer.hasAttachments == False:
        print "Error: attachments not activated on layer"

#handle all features
def input(self,feature):                                                                
    FeatureID = str(int(feature.getAttribute("OBJECTID")))
    attpath = feature.getAttribute("att.path")                                          
    UploadAtt = FeatureLayer.addAttachment(FeatureID, attpath)                         

    AttachID = str(UploadAtt["addAttachmentResult"]["objectId"])

    self.pyoutput(feature)

def close(self):                                                                        
    pass`
larsdevries commented 8 years ago

And I'm using the latest version, only today (3/18/2016) I downloaded the master version.

achapkowski commented 8 years ago

@larsdevries - issue resolve, please pull the latest.