Not able to upload attachments

1011
6
08-14-2018 03:25 AM
deleted-user-jQabWmRafJc9
New Contributor III

We're using ArcGIS SDK to develop a native mobile application. We have Enabled Attachments for the feature layer we published to ArcGIS Online. This is what we encounterd when trying to add an attachment using the 

addAttachment method -
Error Domain=com.esri.arcgis.runtime.error Code=15 "Cannot call this method in this context" UserInfo={NSLocalizedFailureReason=Unable to edit attachments., NSLocalizedDescription=Cannot call this method in this context, Additional Message=Unable to edit attachments.}
If we open this feature layer in map viewer on PC, we can add attachments without an issue.
Any ideas why we are not able to add attachments programmatically using the SDK?
0 Kudos
6 Replies
MichaelDavis3
Occasional Contributor III

Is your app properly licensed for editing?

0 Kudos
MichaelDavis3
Occasional Contributor III

Sorry - I realize now you are editing directly against a feature service an not using an offline database.

0 Kudos
deleted-user-jQabWmRafJc9
New Contributor III

Hi Michael,

Thanks for your reply. We are indeed trying to edit features (add attachment in this instance) in an offline database. We have synced the feature layer and are trying to upload a photo there. At this stage, our app is licensed for developers use only.

0 Kudos
DiveshGoyal
Esri Regular Contributor

Just a guess, but maybe the feature you're trying to add the attachment to isn't "loaded". We actively prevent edits to features that aren't in the loaded state.

Can you try calling the "load()" method on the feature first, and after it finishes loading see if the addAttachment() call works.

We expect calling asynchronous methods like addAttachment() would internally first load the feature, but maybe it was missed in this particular case

0 Kudos
deleted-user-jQabWmRafJc9
New Contributor III

Thanks for the suggestion, Divesh. We have given it a try but was still not able to luck out. addAttachment() still does not work after we have loaded the feature using the load() method.

Any other suggestions?

0 Kudos
DiveshGoyal
Esri Regular Contributor

Hmmm, i can't think of any. We'll have to debug into your data to see what could be going wrong?

Can you share your .geodatabase file with us and provide some code that shows how you're trying to add an attachment to it

0 Kudos