美好的一天。AWS APigateway JS SDK + IAM + PUT + Body =错误
我正在使用AWS APIGateway的自动生成的JS SDK来执行PUT
请求。我有一个身份池,因此在PUT
方法上启用了IAM身份验证。
我必须使用IAM权威性的工作就好了一个GET
请求(apigClient.userProfileGet
),所以我不怀疑这是我的策略配置。
我面临的问题是,只要我将身体添加到请求中,我就会得到非常模糊的The request signature we calculated does not match the signature you provided
错误消息。
我的代码样本如下:
apigClient = apigClientFactory.newClient({
accessKey: AWS.config.credentials.accessKeyId,
secretKey: AWS.config.credentials.secretAccessKey,
sessionToken: AWS.config.credentials.sessionToken,
region: 'eu-west-1'
});
let firstName = document.getElementById('firstName_update').value;
let lastName = document.getElementById('lastName_update').value;
let profilePic = document.getElementById('profilePic_update').value;
let body = {
'firstName': firstName,
'lastName': lastName,
'profilePic': profilePic
};
apigClient.userProfilePut({
'cognito-id-token': session.getIdToken().getJwtToken(),
'g-id-token': null,
'fb-access-token': null
}, body).then(data => {
console.log(data);
});
如果我删除IAM身份验证,该方法执行罚款,我得到我从后端期待的回应。
如果我离开IAM认证,但删除身体,该方法执行,我得到我期望从我的后端的错误响应(如“错误,参数身体缺失”)。
很显然,我需要能够发送请求体..
我在做什么错?
非常感谢
编辑:
我的要求的身体模型,如下所示:
{
"$schema" : "http://json-schema.org/draft-04/schema#",
"title" : "UserDataUpdateRequest",
"type" : "object",
"properties" : {
"firstName": { "type": "string"},
"lastName": { "type": "string" },
"profilePic": { "type": "string" }
},
"required": [ "firstName", "lastName", "profilePic" ]
}
非常抱歉!听起来很沮丧。感谢您记录详细的答案。 –