我试图按照你的步骤连接到你的API,但我真的不知道如何开始……第一次尝试是通过AJAX进行Javascript通信,下面是它的代码:
$.ajax({
url: 'https://api.clockify.me/api/auth/token/',
method: 'POST',
cache: false,
contentType: 'application/json',
headers: {
'X-Api-Key': 'MyAPIKey'
},
data: { "email": "MyMail", "password": "MyPass" },
always: function(r){
console.log(r);
}
});在响应时,我经常会遇到这样的错误:
{"message":"Could not read document: Unrecognized token 'email': was expecting ('true', 'false' or 'null')\n at [Source: java.io.PushbackInputStream@5cfd6511; line: 1, column: 7]; nested exception is com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'email': was expecting ('true', 'false' or 'null')\n at [Source: java.io.PushbackInputStream@5cfd6511; line: 1, column: 7]","code":3002}接下来,我试着继续从PHP开始通信,并使用CURL来做auth和所有事情,但是我总是碰到同样的错误/问题。
我是不是错过了什么?
发布于 2018-08-24 10:50:44
X-Api-Key来获得身份验证令牌。JSON.stringify:$.ajax({
url: 'https://api.clockify.me/api/auth/token/',
method: 'POST',
contentType: "application/json",
data: JSON.stringify({
email: "someone@example.com",
password: "secretpass"
}),
always: function(r) {
console.log(r);
}
});https://stackoverflow.com/questions/52002229
复制相似问题