I have an Silverlight application from which I'm trying to create new features to ArcGIS server. Every time I get error
{\"error\":{\"code\":400,\"message\":\"Unable to complete operation.\",\"details\":[\"Invalid parameters\"]}}
My request code is like this:
System.Net.WebClient client = new System.Net.WebClient();
client.Headers["Content-type"] = "application/x-www-form-urlencoded";
client.Encoding = System.Text.Encoding.UTF8;
client.UploadStringCompleted += client_UploadStringCompleted;
client.UploadStringAsync(new Uri("http://.../FeatureServer/0/addFeatures?f=json&features"), "POST", JSONString);
If I copy the JSONString variable to a text editor, replace every escaped double quote mark (\") with double quote mark (") and use the ArcGIS servers /FeatureServer/0/addFeatures form, I am able to store the same features in that form to a featurelayer. That makes me thinking that the JSON data is well formed and valid for the featurelayer I'm using.
What could make the request response an error every time when called ArcGIS server from Silverlight application?
SOLVED:
I followed the instructions below and found a solution. First, the endpoint URL is like features=[{"geometry":{"x":0,"y":0}, "attributes":{"Id":"018-00","SV":"","Num":"4 A"}}]&f=json/.../FeatureServer/0/addFeatures, not like /.../FeatureServer/0/addFeatures?f=json?features
Found the solution from here and by comparing the POST methods made from my application and the web form with Fiddler
fandfeatures. These parameters will need to be in the proper url-encoded format, which is not the same as what you enter in the REST page form. In any case, I suggest you try the FeatureLayer class. You do not need to add it to the map as most samples suggest. You can then either keep on using it, or capture with Fiddler what the correct request sent by the FeatureLayer looks like. – Petr Krebs Oct 2 '12 at 17:12