post request (with body) in node.js

90 views Asked by At

I want to do a POST request which contains a body, I did that with postman but I failed to write that in node.js after many attempts. Here is a screen in postman which shows the request :

(fixed)

Thanks !

1

There are 1 answers

0
schankam On

I think you can try to send the data doing:

req.write(data);
req.end();

You also need to declare the Content-Length value

'Content-Length': Buffer.byteLength(data)

I haven't actually tried it, but usually I send post data this way. Hope this could help.