AnsweredAssumed Answered

SEC7127: Redirect was blocked for CORS request after submitting geprocessing job

Question asked by jbailey.spatialbridge on Feb 7, 2017
Latest reply on Feb 8, 2017 by jbailey.spatialbridge

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?

Outcomes