我无法使用 Node js 中的 Clockify API 添加新客户端。以下 axios 发布请求返回错误消息:“访问此资源需要完全身份验证”。但是,我可以使用具有相同 API 密钥的 axios.get() 方法获取客户端列表,所以我不确定为什么发布请求说我没有经过身份验证。请让我知道我错过了什么
async function addNewClient(clientName) {
return response = await axios.post(`${url}/workspaces/${workspaceId}/clients`, {
data: {
'name': clientName
},
headers: {
'X-Api-Key': CLOCKIFY_API_KEY,
'Content-Type': 'application/json',
},
}).catch(function (error) {
console.log(error.response.data.message);
return
});
}