- Newest
- Most votes
- Most comments
The issue you're experiencing with multipart/form-data encoded POST requests returning a 403 Forbidden error in API Gateway HTTP API is likely related to the way API Gateway handles this specific content type.
While API Gateway generally supports various content types, including multipart/form-data, there are some considerations and potential limitations when using this format, especially with IAM authorization:
-
Content-Type header: Ensure that your request includes the correct Content-Type header (multipart/form-data) and that it's properly formatted.
-
IAM policy: Check your IAM policy to make sure it explicitly allows the multipart/form-data content type. You may need to add a condition to your policy that includes this specific content type.
-
API Gateway configuration: Verify that your API Gateway is configured to accept and pass through multipart/form-data requests. This may involve adjusting the binary media types settings in your API configuration.
-
Request body parsing: API Gateway might be having issues parsing the multipart/form-data request body. You could try adjusting the request body parsing options in your API Gateway settings.
-
VPC Link configuration: Since you're using a VPC link, ensure that the network path between API Gateway and your VPC resources is correctly set up and that there are no security group or network ACL rules blocking the traffic.
-
Payload size: Check if the payload size exceeds API Gateway limits. There are size restrictions for requests, which could potentially trigger a 403 error if exceeded.
-
CORS settings: If this is a cross-origin request, ensure your CORS settings in API Gateway are correctly configured to allow the multipart/form-data content type.
To troubleshoot further:
- Try using a simpler content type (like application/json) to isolate whether the issue is specific to multipart/form-data.
- Check CloudWatch Logs for more detailed error messages that might not be visible in the access logs.
- Consider using API Gateway REST API instead of HTTP API, as it might offer more flexibility in handling complex content types.
If the issue persists after checking these points, you may need to contact AWS support for more specific guidance on your API Gateway configuration.
Sources
Cors policy with cloudfront + Api Gateway (VPC Links) | AWS re:Post
Requests to API Gateway fail with CORS error if I add headers. | AWS re:Post
CORS Access-Control-Allow-Origin Header missing - Api Gateway HTTP / EC2 | AWS re:Post
Relevant content
- asked 2 years ago
- asked 10 months ago

Thanks, this is somewhat useful but could I get some clarification on the points below please: 3. Verify API Gateway configuration: how does one adjust the binary media types settings in an API Gateway HTTP API? 4. I use the passthrough setting so does the API Gateway do any request parsing? Can you point me to the documentation about request body parsing for API Gateway HTTP APIs?