<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using esriRequest to make POST changes to REST feature using updateDefinition? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-esrirequest-to-make-post-changes-to-rest/m-p/632458#M59036</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What are you trying to update exactly? It sounds like your trying to update data in the feature service and not necessarily the definition itself. Are you trying to update features or the definition? Can you explain from a business perspective on what you are trying to accomplish?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 14 Jul 2018 20:22:23 GMT</pubDate>
    <dc:creator>ChadFoley</dc:creator>
    <dc:date>2018-07-14T20:22:23Z</dc:date>
    <item>
      <title>Using esriRequest to make POST changes to REST feature using updateDefinition?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-esrirequest-to-make-post-changes-to-rest/m-p/632457#M59035</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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.&amp;nbsp; For debugging purposes, I've modified this example:&amp;nbsp;&lt;A class="link-titled" href="https://developers.arcgis.com/javascript/latest/sample-code/request/index.html" title="https://developers.arcgis.com/javascript/latest/sample-code/request/index.html"&gt;Request data from a remote server | ArcGIS API for JavaScript 4.8&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm able to plug in the Feature Service to properly get a response using GET, but&amp;nbsp; 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:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;var item = { &lt;BR /&gt; "minScale" : 10,&lt;BR /&gt; "maxScale" : 0&lt;BR /&gt; };&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; var formData = new FormData();&lt;/P&gt;&lt;P&gt;for ( var key in item ) {&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;formData.append(key, item[key]);&lt;BR /&gt; };&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;// Make the request on a button click using the&lt;BR /&gt; // value of the 'input' text.&lt;BR /&gt; on(btnQuery, "click", function() {&lt;BR /&gt;&amp;nbsp;console.log('POSTing....')&lt;BR /&gt;&amp;nbsp;var url = input.value;&lt;BR /&gt;&amp;nbsp;esriRequest(url, {&lt;BR /&gt;&amp;nbsp;responseType: "json",&lt;BR /&gt;&amp;nbsp;method: "post",&lt;BR /&gt;&amp;nbsp;body: formData&lt;BR /&gt;}).then(function(response) {&lt;BR /&gt; console.log('response', response);&lt;BR /&gt; var responseJSON = JSON.stringify(response, null, 2);&lt;BR /&gt; resultsDiv.innerHTML = responseJSON;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Essentially, just taking the 'item' JSON and converting it to FormData and then using FormData as the&amp;nbsp; payload. Additonally, the URL that isbeing used is of the format:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;A _jive_internal="true" href="https://community.esri.com/server.domain.com/arcgis/rest/services/HM/Production/FeatureServer/0/updateDefinition" rel="nofollow" target="_blank"&gt;https://server.domain.com/arcgis/rest/services/HM/Production/FeatureServer/0/updateDefinition&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here, I am simply appending 'updateDefiniton' as the method to use for modifying the service, as documented here:&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/rest/services-reference/update-definition-feature-layer-.htm#GUID-ED0E2F5D-3B90-44A7-8012-DDFB4272B95E" title="https://developers.arcgis.com/rest/services-reference/update-definition-feature-layer-.htm#GUID-ED0E2F5D-3B90-44A7-8012-DDFB4272B95E"&gt;Update Definition (Feature Layer)—ArcGIS REST API: Services Directory | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't get any errors, and there are obviously no changes being made.&amp;nbsp; Do I need to adjust any settings onthe Feature Service itself? Am I missing something?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Jul 2018 18:36:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-esrirequest-to-make-post-changes-to-rest/m-p/632457#M59035</guid>
      <dc:creator>NickRobles2</dc:creator>
      <dc:date>2018-07-14T18:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using esriRequest to make POST changes to REST feature using updateDefinition?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-esrirequest-to-make-post-changes-to-rest/m-p/632458#M59036</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What are you trying to update exactly? It sounds like your trying to update data in the feature service and not necessarily the definition itself. Are you trying to update features or the definition? Can you explain from a business perspective on what you are trying to accomplish?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Jul 2018 20:22:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-esrirequest-to-make-post-changes-to-rest/m-p/632458#M59036</guid>
      <dc:creator>ChadFoley</dc:creator>
      <dc:date>2018-07-14T20:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using esriRequest to make POST changes to REST feature using updateDefinition?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-esrirequest-to-make-post-changes-to-rest/m-p/632459#M59037</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;At the moment, you can see that I am just trying to update the definition. I tried something&amp;nbsp; simple like minScale. Eventually I Would like to create a feature service using JSON and POST&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 14 Jul 2018 22:04:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/using-esrirequest-to-make-post-changes-to-rest/m-p/632459#M59037</guid>
      <dc:creator>NickRobles2</dc:creator>
      <dc:date>2018-07-14T22:04:12Z</dc:date>
    </item>
  </channel>
</rss>

