I think that your feature service doesn't support editing. Can you verify that the debug message is written and the feature and the FeatureTable has correct values indicating that the edit can be done.
var featureTable = new ServiceFeatureTable(new Uri(url));
await featureTable.LoadAsync();
if (!featureTable.IsEditable || !featureTable.HasAttachments)
throw new Exception("Editing attachments not supported");
var query = await featureTable.QueryFeaturesAsync(new QueryParameters() { WhereClause = "1=1" });
var feature = query.First() as ArcGISFeature;
if (!feature.CanEditAttachments)
throw new Exception("Cannot edit attachment on this feature");
var fileBytes = File.ReadAllBytes(@"C:\Temp\P1050951.JPG");
var attachment = await feature.AddAttachmentAsync("test.jpg", @"image/", fileBytes);
Hi Antti, thank you for the comment
Feature service attachment enabled and editable but the debug message is giving value false.Why is it so? How to make the feature editable? I am working with Arcgis runtime SDK for Xamarin
You might need to load the feature to get the information loaded to it before using the feature.
var feature = query.First() as ArcGISFeature;
await feature.LoadAsync(); // load feature to get the metadata
if (!feature.CanEditAttachments)
throw new Exception("Cannot edit attachment on this feature");
...more stuff
We tried your LoadAsync code. 'CanEditAttachments' returns false. How to enable it?
Thank you
Here is a doc to hosted services.
Can you have a look into your service and make sure that the your service has `HasAttachements` set to true and you can see `AddAttachement` rest endpoint in the service. You can access the later by investigating existing feature in the service.
Here is a example how to access the feature endpoint
Are you using hosted feature services or are they published through ArcGIS Server?
HasAttachment is set to true and also able to fetch attached image from feature service from ArcGIS online. We are using hosted feature service.
How can we enable CanEditAttachments?
Can you share your service definition in whole? You can send it to my mail akajanus@esri.com.
Please check the mail
Did you identify why CanEditAttachments was returning false to you?