문제

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"

도움이 되었습니까?

해결책

Just try it like this:

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top