我必须发出两个HTTP POST请求。 以下是第一个请求。
function getJobId() {
var url = "https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/submitJob";
$.post(url, parameters, function (data, status) {
console.log("Response => ", data);
var responseObj = JSON.parse(data);
var jobId = $.trim(responseObj.jobId);
console.log("JobId => ", jobId);
console.log("JobId length => ", jobId.length);
getOutStops(jobId);
});
}
根据我从此请求获得的响应,我使用上面提到的jobId发出另一个POST请求。 以下是第二个POST请求的代码。
function getOutStops(jobId) {
// Assume jobId = "adhasjdn123123"
var url = "https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/" + jobId + "/results/out_stops";
// when I append the jobId to the URL it gives 400 error.
// But when I hardcode the jobId to URL for eg:
// var url = "https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/adhasjdn123123/results/out_stops";
// The above URL is giving successful output. Even tho both are same.
// not sure why??
$.post(url, params, function (data, status) {
console.log("responseText => ", data);
var responseObj = JSON.parse(data);
var stopList = responseObj.value.features;
parseStops(stopList);
});
}
当我附加jobId并发出请求时,它会抛出400错误。但是当我对网址进行硬编码时,例如:
var url = "https://logistics.arcgis.com/arcgis/rest/services/World/VehicleRoutingProblem/GPServer/SolveVehicleRoutingProblem/jobs/1234567890/results/out_stops";
然后我获得了成功的输出。
不确定我做错了什么。