A2oz

What is Error 400 on AWS API Gateway?

Published in AWS API Gateway 2 mins read

Error 400, also known as "Bad Request," on AWS API Gateway indicates that the request sent to the API endpoint is invalid or malformed. This means the API Gateway cannot process the request as it is missing required information, has incorrect data format, or contains invalid parameters.

Here are some common reasons for a 400 error:

  • Missing required parameters: The request might be missing one or more mandatory parameters required by the API endpoint.
  • Incorrect data format: The data provided in the request might not match the expected format (e.g., incorrect date format, invalid JSON structure).
  • Invalid values for parameters: The values provided for certain parameters might not be valid or fall outside the acceptable range.
  • Incorrect HTTP method: The request might be using the wrong HTTP method (e.g., using POST instead of GET for a read operation).
  • Exceeding request limits: The request might exceed the defined limits for the API Gateway, such as maximum request size or number of parameters.

Troubleshooting Error 400:

  • Check the API documentation: Refer to the API documentation to ensure you understand the required parameters, data formats, and allowed values.
  • Review your request: Carefully examine your request payload and headers to identify any missing or incorrect information.
  • Use API Gateway's error responses: API Gateway provides detailed error messages that can help you understand the specific reason for the 400 error.
  • Test with different clients: Test your request using different clients or tools to rule out any client-side issues.
  • Check API Gateway settings: Verify that your API Gateway configuration is correct, including authorization settings and request limits.

Example:

Imagine you are sending a request to an API endpoint that requires a parameter named userId. If you forget to include this parameter in your request, you would likely receive a 400 error.

Solution:

Ensure that your request includes the userId parameter with the correct data type and value.

Related Articles