<?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 Uploading file to Geoprocessing Service returns result as html instead of json (ArcGis JS 4.7) in ArcGIS Server with JavaScript API Questions</title>
    <link>https://community.esri.com/t5/arcgis-server-with-javascript-api-questions/uploading-file-to-geoprocessing-service-returns/m-p/780570#M166</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to upload file to Geoprocessing service and then get ItemID of uploaded file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;As i use ArcGis JS Api 4.7 my code is following :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let formdata = new FormData();&lt;/P&gt;&lt;P&gt;formdata.append("file", filedata);&lt;BR /&gt;&lt;SPAN&gt; let url = '&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fserver%2Fgis%2Frest%2Fservices%2Futils%2FExcelToTable%2FGPServer%2Fuploads%2Fupload%27%3B" rel="nofollow" target="_blank"&gt;https://server/gis/rest/services/utils/ExcelToTable/GPServer/uploads/upload';&lt;/A&gt;&lt;BR /&gt; let options: __esri.requestEsriRequestOptions =&lt;BR /&gt; {&lt;BR /&gt; body: formdata,&lt;BR /&gt; callbackParamName: 'callback',&lt;BR /&gt; responseType: 'json'&lt;BR /&gt; };&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #595959; background-color: #f8f8f8;"&gt;esriRequest&lt;/SPAN&gt;(url, options).then(function (result) {&lt;BR /&gt; // The requested data&lt;BR /&gt; var geoJson = result.data;&lt;BR /&gt; //let itemID = result["item"].itemID&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It works fine. It uploads file and returns result. But result is html, not json. Once i set &lt;SPAN&gt;responseType: 'json' , it causes error "Unexpected token &amp;lt; in JSON at position 0"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;So question is how to get json result or any way to get ItemID of uploaded file&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Jun 2018 08:34:35 GMT</pubDate>
    <dc:creator>SergeyVladimirov</dc:creator>
    <dc:date>2018-06-01T08:34:35Z</dc:date>
    <item>
      <title>Uploading file to Geoprocessing Service returns result as html instead of json (ArcGis JS 4.7)</title>
      <link>https://community.esri.com/t5/arcgis-server-with-javascript-api-questions/uploading-file-to-geoprocessing-service-returns/m-p/780570#M166</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need to upload file to Geoprocessing service and then get ItemID of uploaded file.&amp;nbsp;&lt;/P&gt;&lt;P&gt;As i use ArcGis JS Api 4.7 my code is following :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;let formdata = new FormData();&lt;/P&gt;&lt;P&gt;formdata.append("file", filedata);&lt;BR /&gt;&lt;SPAN&gt; let url = '&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2Fserver%2Fgis%2Frest%2Fservices%2Futils%2FExcelToTable%2FGPServer%2Fuploads%2Fupload%27%3B" rel="nofollow" target="_blank"&gt;https://server/gis/rest/services/utils/ExcelToTable/GPServer/uploads/upload';&lt;/A&gt;&lt;BR /&gt; let options: __esri.requestEsriRequestOptions =&lt;BR /&gt; {&lt;BR /&gt; body: formdata,&lt;BR /&gt; callbackParamName: 'callback',&lt;BR /&gt; responseType: 'json'&lt;BR /&gt; };&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #595959; background-color: #f8f8f8;"&gt;esriRequest&lt;/SPAN&gt;(url, options).then(function (result) {&lt;BR /&gt; // The requested data&lt;BR /&gt; var geoJson = result.data;&lt;BR /&gt; //let itemID = result["item"].itemID&lt;BR /&gt; });&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It works fine. It uploads file and returns result. But result is html, not json. Once i set &lt;SPAN&gt;responseType: 'json' , it causes error "Unexpected token &amp;lt; in JSON at position 0"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;So question is how to get json result or any way to get ItemID of uploaded file&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Jun 2018 08:34:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-server-with-javascript-api-questions/uploading-file-to-geoprocessing-service-returns/m-p/780570#M166</guid>
      <dc:creator>SergeyVladimirov</dc:creator>
      <dc:date>2018-06-01T08:34:35Z</dc:date>
    </item>
  </channel>
</rss>

