Reputation: 315
I would like to call an api with a header and body for admin user delete a user data like this:
apiClient.post('***endpoint***',
{ tableName: '***',
id: id },
{
headers: {
Authorization: accessToken
}
})
and I want to show the detail in lambda first before I write any function to access my db:
var AWS = require('aws-sdk')
AWS.config.update({ region: '***' })
var ddb = new AWS.DynamoDB()
exports.handler = async function (event , ctx , callback) {
return event
};
and in APIGATEWAY, I set the following
{
"Authorization" : "$input.params('Authorization'),
"body" : $input.json('$')
}
with content-type isapplication/json
in Integration Request
Then when I test the api in Method Test .
In Header , I type "testaccesstoken"
,
In body , I type { "id":"1", "tableName":"test"}
,
But the result is{
"Authorization": "",
"body": {
"id": "1",
"tableName": "test"
}
}
Can anyone explain to me why I still cannot get the header?
Also when I test in poseman,I try like this:,
and I get an error
I hv already deployed the API but why I cannot test in postman??
Upvotes: 0
Views: 1069
Reputation: 16127
In your Postman, set your header is Authorization
instead of "Authorization"
Upvotes: 1
Reputation: 383
I noticed you mentioned the mapping template and passthrough behavior but nothing about mapping it in your Method Request or the header field in Integration Request in API Gateway. There is a recent answer here I think may give you some things to verify are set correctly, as I suspect that may be the issue.
It also covers using a proxy integration instead, let me know if there is a more specific issue in the comments and I'll adjust my answer if needed!
Upvotes: 0