Using an api key in amazon api gateway

0 votes

I have created an api key and added it to my functions. I have then deployed the api and tested it but still get:

"message": "Forbidden"

How do I pass the key into my JSON request as I have been using "x-api-key": "theKey"?

Apr 20, 2018 in AWS by Flying geek
• 3,150 points
161 views

2 answers to this question.

0 votes

The    x-api-key  parameter is passed as an HTTP header parameter which is not added to the JSON body. How you pass HTTP headers depend on the HTTP client you use.

For example, if you use curl and assuming that you POST the JSON payload, a request would look something like (where you replace [api-id] with the actual id and [region] with the AWS region of your API):

$ curl -X POST -H "x-api-key: theKey" -H "Content-Type: application/json" -d '{"key":"val"}' https://[api--id].execute-api.[region].amazonaws.com
answered Apr 20, 2018 by Cloud gunner
• 4,260 points
0 votes
Try with this X-Api-Key
answered Apr 17 by sampath
The same way mentioned by @Cloud gunner?

Related Questions In AWS

0 votes
1 answer

Using an API Gateway in conjunction with microservices and JWTs?

This is how we went about it... What ...READ MORE

answered Oct 17, 2018 in AWS by Priyaj
• 56,160 points
62 views
0 votes
1 answer

How do I create folder under an Amazon S3 bucket through PHP API?

Of Course, it is possible to create ...READ MORE

answered Apr 24, 2018 in AWS by anonymous
1,950 views
0 votes
1 answer

Problem with Swift API Gateway key authorizatiion Ask

Try to add all the headers that ...READ MORE

answered Jun 12, 2018 in AWS by Cloud gunner
• 4,260 points
40 views
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,160 points
99 views
+13 votes
2 answers
+1 vote
3 answers

Log in to AWS using Access Key ID and Secret Access Key ID

Access keys consist of an access key ...READ MORE

answered Aug 17, 2018 in AWS by Priyaj
• 56,160 points
183 views
+1 vote
1 answer