0 votes
1 view
in AWS by (16.7k points)

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 API key with my JSON request as I have been using "x-api-key": "theKey"?

1 Answer

0 votes
by (39.6k points)

The x-api-key is being passed to the HTTP header as a parameter. The HTTP client decides the way it is passed. For instance, if you use curl and also you POST the JSON payload, a request would look like this:

$ curl -X POST -H "x-api-key: theKey" -H "Content-Type: application/json" -d '{"key":"val"}' https://[api-id].execute-api.[region].amazonaws.com

...