Reputation: 1222
I am trying to call my api for a post webservice from a Node application. I successfully pulled data from this same api with a get method, so connexion works perfectly. Now I want to make a push
request({
method: 'POST',
url: ws.url,
json: {"id": 78, "product" : "MyProduct"}
}, function (error, response,body) {
console.log('error ',error);
console.log('body ',body);
console.log('response ',response);
cb(error, response)
//console.log(error, response)
})
I ve got these console.log :
error undefined
body undefined
response { errMsg: 'id not provided ' }
So the response is quite explicit, API havent received my id. However when I call manually same ws with Postman, it works normally.
So what s wrong with my json param? should I send it another way? My webservice needs to have this content in its body and nothing else:
{"id": 78, "product" : "MyProduct"}
Upvotes: 0
Views: 23
Reputation: 1222
I found my issue, and in fact the project where I am working extended Request library, and issue is in the method that overrode Request original behaviour. So to sum up, my code above is supposed to work, I just have to fix this dirty override.
Upvotes: 0