Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/423.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用UCWA API向用户发送消息_Javascript_Node.js_Httprequest_Ucwa - Fatal编程技术网

Javascript 使用UCWA API向用户发送消息

Javascript 使用UCWA API向用户发送消息,javascript,node.js,httprequest,ucwa,Javascript,Node.js,Httprequest,Ucwa,我会通过向客户端发送post请求来尝试UCWAAPI。这是我的建议 应用程序初始化后,我创建了我的请求 const request = require('request-promise'); ... let URL= "https://************.lync.com" let req= { url: URL + body.communication.startMessaging, method: 'POST', headers: { "Acc

我会通过向客户端发送post请求来尝试UCWAAPI。这是我的建议

应用程序初始化后,我创建了我的请求

const request = require('request-promise');
...

let URL= "https://************.lync.com"
let req= {
    url: URL + body.communication.startMessaging,
    method: 'POST',
    headers: {
        "Accept": "application/json; charset=utf-8",
        "authorization": "Bearer " + APP.Token
    },
    body: {
        importance:"Normal",
        sessionContext:"33dc0ef6-0570-4467-bb7e-49fcbea8e944",
        subject:"Sample Subject Line",
        telemetryId:null,
        to:"sip:hamza@opencircle.co",
        operationId:"5028e824-2268-4b14-9e59-1abad65ff393"
    },
    json:true
}
return new Promise((resolve,reject)=> {
    console.log(req);
    request(req).then(res=> {console.log("OK",res)},err=> console.log("ERRoR",err.message)).catch(err=>console.log("ERROR CATCH",err));
})
我收到了这个错误消息

'400-{“代码”:“BadRequest”,“子代码”:“CallbackUriUnreachable”,“消息”:“引发了类型为'PlatformService.Web.ValidationException\'的异常”,“调试信息”:{“errorReportId”:“A8034D8AD14C4B0695F778DC12C19FE”}


您是否为
请求
使用特定的库?乍一看,您似乎没有将
operationId
之类的值嵌入POST请求的主体中。我正在使用请求承诺库OK,您可以尝试在名为
formData
的属性下设置的参数吗?类似于。我已将其更改为github上的请求承诺包中提到的body not form data,但仍然存在以下错误:
400-{“code”:“BadRequest”、“subcode”:“CallbackUriUnreachable”、“message”:“抛出了类型为'PlatformService.Web.ValidationException'的异常”。,“debugInfo”:{“errorReportId”:“0EA13FC537AB4ABABCDC9FAAD2E28746”}}
您是否添加了
json:true
选项?另外,
body.communication.startMessage
是否包含有效路径?