bberdel

Has anyone successfully called "addToDefinition" for a feature layer?

Discussion created by bberdel on Nov 26, 2013
Latest reply on Apr 23, 2014 by bberdel
Hello,

I am trying to call the REST service "addToDefinition" from within my C# code for a feature layer (that requires a token) that I havepublished to my ArcGIS online account.

I am using the RestSharp library to instantiate/manage the REST call.

This is the API reference provided by ESRI:

http://resources.arcgis.com/en/help/arcgis-rest-api/#/Add_To_Definition_Feature_Layer/02r300000228000000/

The problem is that I keep getting "error code: 400 Object reference not set to an instance of an object".

I have verified that I am pointing at the correct URL for updating the feature layer:

http://services.arcgis.com/MyOrganizationID/arcgis/admin/services/LayerName.FeatureServer/0/addToDefinition

It looks as if the "f" and "token" parameters cannot be part of the request body, or the service will not find them. So I have added them as parameters to the URL of the REST service, and everything is getting through at that level.

The problem is that when I add the "fields" parameter to the body of the request, I get the error 400 code. I have tried adding it as a post parameter, a serialized object, a serialized string, but I keep getting the same error. It's almost as if the parameter isn't being accepted by the service.

When I copy and paste the same "fields" parameter my C# is trying to pass to the REST service directly into the REST parameter for on the services.arcgis.com link, it works just fine.

Has anyone come across this before/been able to successfully call this REST service from C# code?

Any help would be greatly appreciated.

Thanks.

Outcomes