AnsweredAssumed Answered

update feature returns “Cannot call this method in this context: You must load the feature before editing.”

Question asked by robertppn on May 23, 2017
Latest reply on May 24, 2017 by akajanus-esristaff

I'm trying to update the attributes of a feature layer through .Net. But I keep getting this error message: "Cannot call this method in this context: You must load the feature before editing."
Here is my code:

static void Main(string[] args) {

var featureTable = new ServiceFeatureTable(new Uri("https://services7.arcgis.com/yixziXsHssbXEWl5/ArcGIS/rest/services/grex/FeatureServer/0")) {Credential = new ArcGISTokenCredential()};

((TokenCredential) featureTable.Credential).Token = GetToken().access_token;
var queryParams = new QueryParameters {WhereClause = "DeelplanId = 666"};

// Query the feature table
var queryResult = featureTable.QueryFeaturesAsync(queryParams);
// Cast the QueryResult to a List so the results can be interrogated
queryResult.Wait();
var features = queryResult.Result.ToList();

features[0].SetAttributeValue("Kosten", 3562);

Console.ReadKey();
}

It fails on the SetAttributeValue, although I see the attributes are loaded from the server.
Any idea?, thx!

Outcomes