This is almost trivial unless you forget about it and try to research the solution. It's stupidly obscure, probably because it's so trivial.
I am using request to post into some application. I didn't have a convenient boilerplate to reference and the damn internet did not provide a decent example. Here is a working and completely adequate post block:
request.post(
{
url:url,
headers: {
authorization: `${userId} ${authToken}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ propertyName:'propertyValue' })
},
(err, response, body) => {
console.dir({ 'err': err });
console.dir({ 'response': response });
console.dir({ 'body': body });
//callback(err, body);
}
);
This works but it didn't at first. On the receiving end (also nodejs, using express), the call was just fine, came back 200, showed its presence on the far end but, absolutely no post body content. The problem? I had forgotten to include the Content-Type header.