AnsweredAssumed Answered

Uploading file to Geoprocessing Service returns result as html instead of json (ArcGis JS 4.7)

Question asked by kaylask on Jun 1, 2018

I need to upload file to Geoprocessing service and then get ItemID of uploaded file. 

As i use ArcGis JS Api 4.7 my code is following :

 

let formdata = new FormData();

formdata.append("file", filedata);
let url = 'https://server/gis/rest/services/utils/ExcelToTable/GPServer/uploads/upload';
let options: __esri.requestEsriRequestOptions =
{
body: formdata,
callbackParamName: 'callback',
responseType: 'json'
};

 

esriRequest(url, options).then(function (result) {
// The requested data
var geoJson = result.data;
//let itemID = result["item"].itemID
});

 

It works fine. It uploads file and returns result. But result is html, not json. Once i set responseType: 'json' , it causes error "Unexpected token < in JSON at position 0"

So question is how to get json result or any way to get ItemID of uploaded file

Thanks

Outcomes