[英]how to send api_key and api_secret arguments in jquery post request
$.ajax({
type: 'POST',
url: 'http://apius.faceplusplus.com/detection/detect',
crossDomain: true,
cache: false,
async: true,
data: '{ "comment" }',
dataType: 'jsonp',
success: function(responseData) {
alert(JSON.stringify(responseData));
},
error: function (responseData, textStatus, errorThrown) {
alert(JSON.stringify(responseData));
}
});
I am sending a post request to above which requires api_key
and api_secret
parameters for authentication. 我向上面发送了一个发布请求,该请求需要使用
api_key
和api_secret
参数进行身份验证。 I tried sending value of this 2 paramenters like this in above request: 我在上面的请求中尝试发送这2个参数的值:
headers:
{
"Authorization": "Basic " + Base64.encode('value of api key here' + ":" + 'value of api secret here')
},
But when I execute the request it says 400 BAD REQUEST and when I hit the url in browser it shows 但是,当我执行请求时,它说400 BAD REQUEST,当我在浏览器中点击URL时,它显示
{ "error": "MISSING_ARGUMENTS: api_key", "error_code": 1004 }
{“ error”:“ MISSING_ARGUMENTS:api_key”,“ error_code”:1004}
Please suggest me a solution. 请给我建议一个解决方案。 I am stuck for long time.
我被困了很长时间。
在ajax请求的数据对象中传递键/值对,如下所示:
data: '{ "api_key": "thekeyhere", "api_secret": "thesecrethere" }'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.