'Https POST request. 200 in postman 400 in code
I tried to call an endpoint.
- Requests called via Postman ended fine.
- Requests called via Axios or node-fetch library were all ending with 400.
Firstly I tried to match my headers 1:1 with Postman... then, my idea was to compare these requests in Fiddler. Unfortunately, I was able to see there only requests from postman.
- Why I can't see my 400 requests in fiddler? (maybe I am missing some settings there)
- What can potentionaly cause this 400 - Bad request issue? (or any tips for investigation)
Example fake request.
const emailRequest: EmailRequest = {
replyTo: 'test',
subject: 'test',
text: 'test',
};
fetch('https://someaddress.com/sendemail',
{
method: 'post',
headers: {
'Content-Type': 'application/json',
'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate',
Date: 'Tue, 19 Apr 2022 04:59:50 GMT',
server: 'Apache',
'x-content-type-options': 'nosniff',
'X-Correlation-Id': 'b2d3808a-a9da-49a2-97eb-e3a222624062',
'x-frame-options': 'DENY',
'x-xss-protection': '1; mode=block', //check
Authorization:
'Bearer (my bearer)',
},
body: JSON.stringify(emailRequest),
},
)
Thank you very much for your time and ideas.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
