function addFeatures() { addFeaturesUrl = 'http://server/arcgis/rest/services/ClosedRoadsAddress/FeatureServer/2/addFeatures?features=' addAttributesUrl1 = '[{"attributes":{"Address":"'100 Main St'"}}]' var obj1 = encodeURIComponent(addAttributesUrl1); var theUrl1 = addFeaturesUrl + obj1; var xmlHttp = null; xmlHttp = new XMLHttpRequest(); xmlHttp.open( "POST", theUrl1, false ); xmlHttp.send( null ); }
Hi jake
I am trying to modify one attribute in my feature service layer in arcgis 10.2.2 using a json object .
Can u help me briefing out how to make that request . Can i do it without using any of the arcgis api .
regards
saurabh
Hi Saurabh,
Yes, you can do this without the ArcGIS API for JavaScript. Below is an example:
//json
var jsonObject = '{ "employees" : [' +
'{ "firstName":"John" , "lastName":"Doe" }]}';
//parse json
var obj = JSON.parse(jsonObject);
var lastName = obj.employees[0].lastName;
//update URL for feature service
var updateFeaturesUrl = 'http://server/arcgis/rest/services/Employees/FeatureServer/0/updateFeatures?features='
var updateAttributesUrl1 = '[{"attributes":{"OBJECTID":1,"NAME":"' + lastName + '"}}]'
var obj1 = encodeURIComponent(updateAttributesUrl1);
var theUrl1 = updateFeaturesUrl + obj1;
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.open( "POST", theUrl1, false );
xmlHttp.send( null );