Ich benutze "Hackathon-Starter" Knoten Haufen für mein Projekt. . In diesem Build, wenn ich versuche, eine API von request.post es nehmen „'application/x-www-form-urlencoded;charset=utf-8'
Header Inhaltstyp für alle API aufrufen Ich habe versucht, einen Kopfball von API ändern aufrufen, aber es wird nurSetzen Sie den Content-Type-Header auf json für request.post
Inhaltstyp nehmen: ' application/x-www-form-urlencoded;.. charset = utf-8'
Header für alle API ich unten Code versucht haben, ich will Anwendung setzen/json für alle API
var querystring = require('querystring');
var request = require('request');
var form = {
"userType": req.body.type,
"userName": req.body.mobile,
"email": req.body.email,
"name": req.body.name,
"password": req.body.password
};
var formData = querystring.stringify(form);
var contentLength = formData.length;
request.post({
headers: {'content-type':'application/json'},
url:'mylink',
form: formData // I have tried form as well.
},function(error, response, body){
console.log(body)
});
.
Mein Er ror Nachricht auf der Konsole.
{"timestamp":1484822264270,"status":415,"error":"Unsupported Media Type","exception":"org.springframework.web.HttpMediaTypeNotSupportedException","message":"Content type 'application/x-www-form-urlencoded;charset=utf-8' not supported","path":"mylink"}
Ich habe keine Worte für Ihre Hilfe vielen vielen Dank (Multiplizieren * 10K) :). –
Sehr schön, löste mein Problem sofort. –