Select to view content in your preferred language

error trying to post an attachment

6690
17
Jump to solution
09-30-2012 12:51 PM
ChrisRiver
Occasional Contributor
AGSAttachmentManager *attachmentManager = [featureLayer attachmentManagerForFeature:feature]; attachmentManager.delegate = self; [attachmentManager addAttachmentAsJpgWithImage:image name:@"New Image"]; [attachmentManager postLocalEditsToServer];


results in:

Domain=org.brautaset.json.parser.ErrorDomain Code=0 "Illegal start of token [<]" UserInfo=0x910380 {NSLocalizedDescription=Illegal start of token [<]}


Any ideas?
0 Kudos
17 Replies
ChrisRiver
Occasional Contributor
Ok, so I'm back at this again.

What does postLocalEditsToServer /actually/ do?  When I call this method I am seeing no http traffic coming out of the device.  I just get the error:

Domain=org.brautaset.json.parser.ErrorDomain Code=0 "Illegal start of token [<]" UserInfo=0x232b8ff0 


Does postLocalEditsToServer initially try to convert the data into JSON format before sending it off?  That would explain why it is getting hung up and I'm not seeing any traffic (if it is choking on the json conversion process).

Thanks
0 Kudos
ChrisRiver
Occasional Contributor
I was finally able to capture and decrypt some of the traffic coming back from the addAttachment request.  A couple of things I noticed.

1.  I am receiving 403 Forbidden response (which would be the source of the json parse error)
2. The token string seems to be passed in the request querystring, event though it is a POST.  This doesn't make much sense to me, but if there is no token being passed in the header that would explain why I'm getting a 403 (right?)

Any thoughts?

Thanks!
0 Kudos
NimeshJarecha
Esri Regular Contributor
1. Which version of ArcGIS Server are you using?
2. I'm assuming based on information on thread so far that server is secured with token authentication. Is this HTTPS? or HTTP?
3. Could you please post the request/response information you captured (remove sensitive information).

Regards,
Nimesh
0 Kudos
ChrisRiver
Occasional Contributor
1. Which version of ArcGIS Server are you using?

10.1

2. I'm assuming based on information on thread so far that server is secured with token authentication. Is this HTTPS? or HTTP?

Yes that is correct.  Sorry if I didn't make this clear from the beginning.  it is https

3. Could you please post the request/response information you captured (remove sensitive information).

The best I can do is the request/response header info:
Request:

POST /arcgis/rest/services/nih/IncidentMgt/FeatureServer/4/0/addAttachment?token=[MY TOKEN] HTTP/1.1
Host: [HOST IP]
Referer: arcgisios
Accept-Encoding: gzip, deflate
Content-Type: multipart/form-data; boundary=AaB03x
Accept-Language: en-us
Accept: */*
Cookie: AGS_ROLES="CMjxZtgDgUJqTp/x20IHHvxNuLoNDmLPZRtlQhmgzqDVz3AOXJf4Qw=="
Content-Length: 392277
Connection: keep-alive
User-Agent: ArcGISiOS-2.3.2/6.0/x86_64

Response:

HTTP/1.1 403 Forbidden
Cache-Control: private
Content-Type: text/html;charset=utf-8
Content-Encoding: gzip
Server: Microsoft-IIS/7.5
Server: Apache-Coyote/1.1
X-AspNet-Version: 2.0.50727
X-Powered-By: ASP.NET
Date: Fri, 26 Oct 2012 17:13:18 GMT
Content-Length: 356

Thanks!
0 Kudos
ChrisRiver
Occasional Contributor
Through more tedious digging through wireshark I found:

"Error: Error in uploading attachment file, File size or type not supported for this service"

The problem is that I can upload the same image file using the web interface.

Thoughts?
0 Kudos
NimeshJarecha
Esri Regular Contributor
What is the size of file? Are you specifying a file extension?

In the following code line...specify "NewImage.jpg"
[attachmentManager addAttachmentAsJpgWithImage:image name:@"New Image"];

Regards,
Nimesh
0 Kudos
ChrisRiver
Occasional Contributor
Thank you Nimesh, that did it.

If you have a second maybe you could pass on that the documentation here:
http://resources.arcgis.com/en/help/runtime-ios-sdk/concepts/index.html#/Attachment_Manager/00pw0000...

Does not specify that this is required and it shows an example of an image name /without/ a file extension.

Thanks again!
0 Kudos
NimeshJarecha
Esri Regular Contributor
Great! Good to know that it's working now. We'll update the documentation.

Regards,
Nimesh
0 Kudos