i using "request" node module call third party rest services.
here sample code:
request.post({url:'https://myyrl/myfunction', formdata: formdata, function optionalcallback(err, httpresponse, body) { if (err) resolve({"message": err}); else resolve({"message": body}); })
by getting error "the incoming message has unexpected message format 'raw'. expected message formats operation 'xml', 'json'.".
please me how pass headers request.
thanks in advance.
request.post({url:'https://myurl/myfunction', body: formdata, json: true, headers: {'contenttype': 'application/json'}}, function optionalcallback(err, httpresponse, body) { if (err) resolve({"message": err}); else resolve({"message": json.stringify(body)}); });
worked me...
Comments
Post a Comment