Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
119
rated 0 times [  124] [ 5]  / answers: 1 / hits: 37200  / 11 Years ago, mon, january 27, 2014, 12:00:00

I am using the request module in Node.js to do a put request. My code looks like this



var request = require('request');
var data = {foo: bar, woo: car};

request({
method: 'PUT',
uri: myURL,
multipart: [{
'content-type':'application/json',
body: JSON.stringify(data)
}]
}, function(error, request, body){
console.log(body);
});


When I run this I get an error:



Unsupported content with type: application/json


More From » node.js

 Answers
26

Just try it like this:



request({ url: url, method: 'PUT', json: {foo: bar, woo: car}}, callback)


[#72910] Sunday, January 26, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dominics

Total Points: 424
Total Questions: 99
Total Answers: 107

Location: South Korea
Member since Fri, Sep 11, 2020
4 Years ago
dominics questions
Wed, Apr 6, 22, 00:00, 2 Years ago
Thu, Jan 13, 22, 00:00, 2 Years ago
Fri, Sep 18, 20, 00:00, 4 Years ago
;