Tag: kaa

将cURL命令转换为发送通知到kaa服务器的请求

我想发送一个通知给kaa服务器。 下面的cURL命令工作正常,但我想从我的node.js服务器发送POST请求。 请帮助我转换到发布请求。 curl -v -S -u devuser:devuser123 -F'notification= {"applicationId":"32769","schemaId":"32778","topicId":"32770","type":"USER"}; type=application/json' -F file=@notification.json "http://localhost:8080/kaaAdmin/rest/api/sendNotification" | python -mjson.tool 我试过这样的: 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) […]