admin管理员组文章数量:1356097
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.
本文标签: javascriptAWS API gateway returns 400 Bad Requestbut Postman works fineStack Overflow
版权声明:本文标题:javascript - AWS API gateway returns 400 Bad Request, but Postman works fine - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744042574a2580936.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论