Solution 1:

I had to add an API Usage plan, and then link the plan to the API stage.

Seems like this is the only way to link the key to the API, not sure if this is a recent change on AWS.

Solution 2:

The x-api-key parameter is passed as a HTTP header parameter (i.e. it 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

Solution 3:

If you set 'API Key Required' option to true, please check below.

  1. you have to pass 'x-api-key' HTTP Header Parameter to API Gateway.

  2. The API Key had to be created.

  3. In addition, you need to check a Usage Plan for the API Key on API Gateway Console.

Solution 4:

If you set 'API' key required to true, you need to pass the api key as header.

API Key is passed as header field 'x-api-key'. Even after adding this field in header, this issue may occur. In that case, please validate below points

  1. Do you have a Usage Plan? if not need to create one.
  2. Link you API with Usage Plan. For that add a stage, it will link your API
  3. Do you have API Key? if not you need to create an API Key and enable it.
  4. Add the Usage Plan which is linked with your API to this API Key. For that, add Usage Plan.