尝试获取工作结果在 Postman 中完美运行,但在浏览器中使用 AJAX 要求 app_code 和 app_id
Trying to GET a job result works perfectly in Postman, but using AJAX in browser asks for app_code and app_id
我正在尝试使用 HERE 作业 REST API 来获取我的作业结果。我在 Postman 中测试了我的 GET 请求,它使用我的 apiKey 完美运行,无需使用任何额外的 headers(除了 Content-Type:application/octet-stream)。
但是当我尝试使用 AJAX 和 jQuery 尝试相同的请求时,我收到 400 响应告诉我我需要 app_id 和 app_code。
我的代码:
$.ajax({
async: false,
contentType: "application/octet-stream",
type: 'GET',
url: "https://batch.geocoder.ls.hereapi.com/6.2/jobs/{JOB_ID}/result?apiKey={API_KEY}",
}).done(function (result) {
console.log(result);
});
return header:
{"error":"Bad Request","error_description":"The request is missing the app_id and app_code parameters. They must both be passed as query parameters. If you do not have app_id and app_code, please obtain them through your customer representative or at http://developer.here.com/myapps."}
使用这个正常的 link 将它放入我浏览器的 URL 栏时确实有效。
在 REST 下的 https://developer.here.com/projects/ 页面上使用应用程序 ID 和 apikey 作为 api_code 的组合也不起作用。这告诉我这是一对无效的。
我不知道我现在应该实际使用什么凭据。
提前感谢您的帮助!
根据 documentation,您必须使用 apikey
进行身份验证。
请检查 ajax 的代码是否正常工作。
<html>
<button type="button" class="btn">Click me!</button>
<p class="text">Replace me!!</p>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
$('.btn').click(function() {
$('.text').text('loading . . ');
$.ajax({
type:"GET",
url:"https://batch.geocoder.ls.hereapi.com/6.2/jobs/CxnGVvxLZeCjJnGRD0udKgLgeQzNa5xq/result?apiKey={apikey}",
success: function(result) {
$('.text').text(JSON.stringify(result));
console.log(result);
},
});
});
</script>
</html>
希望对您有所帮助。
我正在尝试使用 HERE 作业 REST API 来获取我的作业结果。我在 Postman 中测试了我的 GET 请求,它使用我的 apiKey 完美运行,无需使用任何额外的 headers(除了 Content-Type:application/octet-stream)。
但是当我尝试使用 AJAX 和 jQuery 尝试相同的请求时,我收到 400 响应告诉我我需要 app_id 和 app_code。 我的代码:
$.ajax({
async: false,
contentType: "application/octet-stream",
type: 'GET',
url: "https://batch.geocoder.ls.hereapi.com/6.2/jobs/{JOB_ID}/result?apiKey={API_KEY}",
}).done(function (result) {
console.log(result);
});
return header:
{"error":"Bad Request","error_description":"The request is missing the app_id and app_code parameters. They must both be passed as query parameters. If you do not have app_id and app_code, please obtain them through your customer representative or at http://developer.here.com/myapps."}
使用这个正常的 link 将它放入我浏览器的 URL 栏时确实有效。
在 REST 下的 https://developer.here.com/projects/ 页面上使用应用程序 ID 和 apikey 作为 api_code 的组合也不起作用。这告诉我这是一对无效的。
我不知道我现在应该实际使用什么凭据。
提前感谢您的帮助!
根据 documentation,您必须使用 apikey
进行身份验证。
请检查 ajax 的代码是否正常工作。
<html>
<button type="button" class="btn">Click me!</button>
<p class="text">Replace me!!</p>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
$('.btn').click(function() {
$('.text').text('loading . . ');
$.ajax({
type:"GET",
url:"https://batch.geocoder.ls.hereapi.com/6.2/jobs/CxnGVvxLZeCjJnGRD0udKgLgeQzNa5xq/result?apiKey={apikey}",
success: function(result) {
$('.text').text(JSON.stringify(result));
console.log(result);
},
});
});
</script>
</html>
希望对您有所帮助。