AnsweredAssumed Answered

Using esriRequest to make POST changes to REST feature using updateDefinition?

Question asked by TacoB0T on Jul 14, 2018
Latest reply on Jul 14, 2018 by TacoB0T

I've worked with ajax requests before, but I'm trying to make changes to a Feature Service using updateDefintion but I can't seem to get it to work.  For debugging purposes, I've modified this example: Request data from a remote server | ArcGIS API for JavaScript 4.8 


I'm able to plug in the Feature Service to properly get a response using GET, but  when trying to use a FormData to load JSON as the payload for updateDefinition, I don't get a response. I modified a small amount of data to effectively try to use something simple as:


var item = {
"minScale" : 10,
"maxScale" : 0

var formData = new FormData();

for ( var key in item ) {
   formData.append(key, item[key]);


// Make the request on a button click using the
// value of the 'input' text.
on(btnQuery, "click", function() {
 var url = input.value;
 esriRequest(url, {
 responseType: "json",
 method: "post",
 body: formData
}).then(function(response) {
console.log('response', response);
var responseJSON = JSON.stringify(response, null, 2);
resultsDiv.innerHTML = responseJSON;


Essentially, just taking the 'item' JSON and converting it to FormData and then using FormData as the  payload. Additonally, the URL that isbeing used is of the format:


Here, I am simply appending 'updateDefiniton' as the method to use for modifying the service, as documented here:

Update Definition (Feature Layer)—ArcGIS REST API: Services Directory | ArcGIS for Developers 


I don't get any errors, and there are obviously no changes being made.  Do I need to adjust any settings onthe Feature Service itself? Am I missing something?