error trying to post an attachment

5787
17
Jump to solution
09-30-2012 12:51 PM
ChrisRiver
New Contributor III
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
1 Solution

Accepted Solutions
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

View solution in original post

0 Kudos
17 Replies
NimeshJarecha
Esri Regular Contributor
Is this "feature" belong to feature layer (feature.layer has to be feature layer)? If yes, feature layer's "attachments" property is TRUE?

Regards,
Nimesh
0 Kudos
ChrisRiver
New Contributor III
Thanks for your response Nimesh!

Yes, feature belongs to featureLayer. feature is obtained using the featureLayer:featureWithTemplate method.
I then add a few attributes to the feature, then perform the addFeature operation.  Once features are added I invoke the addAttachmentAsJpgWithImage method with the image, then postLocalEdits.

..and yes, featureLayer's attachment property is set to true.

Hope this helps!
0 Kudos
ChrisRiver
New Contributor III
As a side note, I'm pretty sure the service is set up correctly as I was able to upload an attachment using the web interface.
0 Kudos
NimeshJarecha
Esri Regular Contributor
Are you getting error for your feature layer or any public feature layer as well? If all feature layers then please post a sample application here so I can have a look at it.

Regards,
Nimesh
0 Kudos
ChrisRiver
New Contributor III
Thanks again Nimesh.

I just Saved an attachment to the public feature layer without a problem, so it would seem the issue with with my feature class.

There are a few differences between the public layer and mine, though seemingly insignificant for the most part.  One of the differences though, is that my feature class is of type table, not feature layer.  Could this be causing an issue?
0 Kudos
NimeshJarecha
Esri Regular Contributor
The table should not make any difference. It should just work. Are you testing this on device or simulator? If device, then are you able to browse to rest end point of the layer in device browser?

Regards,
Nimesh
0 Kudos
NimeshJarecha
Esri Regular Contributor
Chris,

Any update on this?

Regards,
Nimesh
0 Kudos
ChrisRiver
New Contributor III
Hi Nimesh, thanks for checking in.

I still have not found a solution to this issue.  The "[<]" leads me to believe that the server is returning an html error page, but I have not yet been able to isolate the actual error.  I have set up a way to sniff for packet traffic to and from my iPad device, but have had to move on to other functionality for the project I'm working on, so haven't had a chance to pursue it any further.

I will update you when I pick up this ball again.  Meanwhile if you have any insights of course they'd be well received 🙂

Thanks
0 Kudos
NimeshJarecha
Esri Regular Contributor
Yes, your guess is correct. Server returns HTML which JSON parser fails to parse and you have that error. Intercepting the request and response will help you. Let me know if you need further help with this whenever you get a chance to look at it.

Regards,
Nimesh
0 Kudos