AnsweredAssumed Answered

FeatureLayer.AddAttachment() does not work properly

Question asked by thomaslaue on Nov 14, 2012
Latest reply on Jan 28, 2013 by harrisjm0101
Hello,

I am currently working on a mobile solution using JQuery Mobile and ArcGIS JavaScript API. I have been developing my own attribute editor as the default ESRI attribute and attachment editor widgets do not match to our style guides. Everything is working so far apart from the attachment handling.

I have been trying adding attachments (mainly images) using the following piece of code:

if (featureayer.isEditable && featureayer.hasAttachments) {      featureayer.addAttachment(selectedFeatureObjectID, document.getElementById("addImageForm"), function (result) {                        ...     },     function (error) {                        ...     });


My application is trying to post the selected image to my local server and I can see the following post request payload using the Chrome developer tools:

------WebKitFormBoundaryqLUYc2Wu8g9s28A1
Content-Disposition: form-data; name="inputFile"; filename="images.jpeg"
Content-Type: image/jpeg


------WebKitFormBoundaryqLUYc2Wu8g9s28A1
Content-Disposition: form-data; name="token"

B8rm1jrQR_Vh0VMZQ1EJ17IXpM284A3C3VmJHvoQC5w19hU5UwuU5TKseEAZTWP8NgaOOjV_4kJRJajyfKtCRw..
------WebKitFormBoundaryqLUYc2Wu8g9s28A1
Content-Disposition: form-data; name="f"

json
------WebKitFormBoundaryqLUYc2Wu8g9s28A1--

However it is always getting back with an error message:


Error: Error performing add attachment operation
Code: 500


Unfortunately, I have no idea what might be the reason of this problem. I can add attachments using ArcGIS Desktop and the ArcGIS Server Rest API via Browser so that I am assuming that this is not a issue with my feature service.

Thank you very much for any hint! Best regards

Thomas

Outcomes