我还没有访问我想要的URL的权限,但是我一直在阅读有关如何与adobe交互的教程,并且该教程指出请求应采用以下格式:
curl -X POST \
https://analytics.adobe.io/api/{COMPANYID}/reports \
-H 'Accept: application/json' \
-H 'Authorization: Bearer {ACCESSTOKEN}' \
-H 'Content-Type: application/json' \
-H 'x-api-key: {APIKEY}' \
-H 'x-proxy-global-company-id: {COMPANYID}' \
-d '{REQUESTJSON}'
相反,我尝试将其编写为javascript中的Ajax请求。我有以下代码:
$("button").on("click", function() {
$.ajax({
dataType: "jsonp",
url: "https://analytics.adobe.io/api/abc/reports",
headers: {
"Accept": "application/json",
"Authorization": "Bearer {ACCESSTOKEN}",
"Content-type": "application/json",
"x-api-key": "{APIKEY}",
"x-proxy-global-company-id": "your key",
},
data: {json: jsondata},
success: function(response) {
console.log(response);
},
error: function(data) {
alert(data);
}
});
});
如果我编写的javascript实际上实现了相同的目的,我正在努力工作,换句话说,如果上面的curl有效,那么此javascript代码是否可以完全复制?我有什么办法可以验证这一点?
谢谢
詹姆斯