Ich möchte eine Benachrichtigung an kaa Server senden. Der folgende cURL-Befehl funktioniert einwandfrei, ich möchte jedoch eine POST-Anfrage von meinem node.js-Server senden. Bitte helfen Sie mir bei der Umstellung auf Post-Anfrage.Convert cURL Befehl zu Post-Anfrage zu senden Benachrichtigung an kaa Server
curl -v -S -u devuser:devuser123 -F'notification=
{"applicationId":"32769","schemaId":"32778","topicId":"32770","type":"USER"};
type=application/json' -F [email protected] "http://localhost:8080/kaaAdmin/rest/api/sendNotification" | python -mjson.tool
Ich habe versucht, wie folgt aus:
var notificationValue= {"applicationId":"32769","schemaId":"32778","topicId":"32770","type":"USER"};
var file = 'notification.json';
var opts = {
url: 'http://localhost:8080/kaaAdmin/rest/api/sendNotification',
method: 'POST',
auth: { user: 'devuser', password: 'devuser123' },
json: true,
formData: {
notification: JSON.stringify(notificationValue),
file : fs.readFileSync(file)
}
};
request(opts, function(err, resp, body) {
if(err)
res.send(err);
else{
res.send(body);
}
});
Ich erhalte: Fehler 400 Teil Erforderliche Anfrage 'Mitteilung' nicht vorhanden ist.
Sie sind fantastisch. Ich danke dir sehr. –