Good day.
I'm using AWS APIGateway's auto-generated JS SDK in order to perform a PUT
request. I have an identity pool, and have therefore enabled IAM auth on the PUT
method.
I have a GET
request (apigClient.userProfileGet
) using the IAM auth working just fine, so I don't suspect it is my policy configuration.
The problem I'm facing is that as soon as I add the body onto the request, I am getting the very vague The request signature we calculated does not match the signature you provided
error message.
A sample of my code is as follows:
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);
});
If I remove the IAM auth, the method executes fine, and I get the response I expect from the backend.
If I leave IAM auth in place, but remove the body, the method executes, and I get the error response I expect from my backend (something like "error, parameters missing in body").
Obviously I need to be able to send the request body..
What am I doing wrong?
Thanks very much
EDIT:
My Request body model looks as follows:
{
"$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" ]
}