Using the ArcGIS for JavaScript API 3.19, I'm submitting a job to the ExtractData geoprocessing service at:
https://analysis7.arcgis.com/arcgis/rest/services/tasks/GPServer/ExtractData/submitJob
The job is submitted and run successfully, and the output is created in my ArcGIS Online root folder.
However, I can't figure out how to get the response back from the server. When I submit the job, the JavaScript console reports 2 errors:
SEC7127: Redirect was blocked for CORS request.
SCRIPT7002: XMLHttpRequest: Network Error 0x800c0014, A redirection problem occurred.
This sort of makes sense to me, because the server issues a redirect to the job page. I can see that the server responds with a status of 303, and includes the URL to the job in the response. However, the code that I have to handle the response (see below) is never called.
var url = _extractDataURL +
"?inputLayers=" + inputLayers +
"&extent=" + extent +
"&clip=" + clip +
"&dataFormat=" + dataFormat +
"&outputName=" + outputName +
"&context=" + context +
"&f=" + f +
"&token=" + IdentityManager.credentials[0].token;
var xmlHTTPRequest = new XMLHttpRequest();
xmlHTTPRequest.onreadystatechange = function () {
if (xmlHTTPRequest.readyState == 4 && xmlHTTPRequest.status == 200) {
console.log(this.responseText);
}
}
xmlHTTPRequest.onload = function () {
console.log(this.responseText);
}
xmlHTTPRequest.open("GET", url, true);
xmlHTTPRequest.send();
How can I configure things so that the redirect (the correct response) doesn't cause the CORS error, and so that I can handle the response and get the URL to the job?
Just to clarify -
- You post your job - [MyServer]\arcgis\....
-> you get a job number back and you poll
- The response comes back with a URL with your completed job on another server? [MyOtherServer]\arcgis\...jobcomplete.
-> When you hit the url you get a CORS error and your responder is never called.
or are you getting a CORS error and hitting the same root server?
Hi Jordan,
No, that's not what's happening. The response to submitJob is a redirect, which I believe is what is causing the CORS issue.