I am using the SendGrid Parse API (/) to get ining email bodies POSTed to an AWS API Gateway.
When I send the webhook to requestb.in I get the responses fine.
When I use Postman to fake a request to my server I get a proper response.
When I tell SendGrid to send the webhook to my server, however, I get a 400 Bad Response error from SendGrid and my server never gets hit (so I assume the API Gateway is throwing the error).
Is there something simple I'm missing? I tried setting up CORS but that wasn't it (or I set it up wrong).
I'm stumped.
Thanks!
I am using the SendGrid Parse API (https://sendgrid./blog/parse-webhook-tutorial/) to get ining email bodies POSTed to an AWS API Gateway.
When I send the webhook to requestb.in I get the responses fine.
When I use Postman to fake a request to my server I get a proper response.
When I tell SendGrid to send the webhook to my server, however, I get a 400 Bad Response error from SendGrid and my server never gets hit (so I assume the API Gateway is throwing the error).
Is there something simple I'm missing? I tried setting up CORS but that wasn't it (or I set it up wrong).
I'm stumped.
Thanks!
Share Improve this question asked May 2, 2016 at 11:56 JustinJustin 211 silver badge3 bronze badges 2- "Server" is a little ambiguous in this context. Can you clarify by distinguishing the test requests you made to your API Gateway endpoint and your backend/integration endpoint? – Lorenzo d Commented May 2, 2016 at 18:02
- 1 Also can you make sure the content-type and accept headers are passing to API Gateway correctly? – Ka Hou Ieong Commented May 2, 2016 at 21:35
1 Answer
Reset to default 7I just debugged an API Gateway issue that was throwing an error message related to CORS and the request was never hitting my server, but the real issue was stemming from the data in the request.
So I have found out that if there is any issue with a request API Gateway will throw a default 400 error saying there was no Allow-Access-Control-Origin header. This can make you believe you have an issue with your CORS. You can eliminate CORS as an issue if you set up a MOCK GET request, make the request in the browser, and verify it returns 200 in the network tab in the browser developer tools.
Once I knew it was ing from only the POST requests it had to be an issue with the data. I was sending a JSON hash without stringifying it. So the solution was to use JSON.stringify(request_data)
.
I would check the data format of the requests. If you add the requests and responses to your question I might be able to help further.