使用UCWA API来安排Lync会议

本文关键字:Lync 会议 UCWA API 使用 | 更新日期: 2023-09-27 18:14:48

我已经用c#认证并授权了UCWA API。应用程序id也是使用生成的令牌生成的。当我尝试使用以下代码创建lync会议时,我得到错误"内部服务器错误"。错误:-

{"code":"ServiceFailure","message":"Your request couldn't be completed.","debugInfo":{"errorReportId":"e2c35f5e0b274c4185d08837dd7e16a3"}}

我的代码是-

onlinemeetingURL = "https://lynctswebint.Mycompany.com/ucwa/oauth/v1/applications/101030060103/onlineMeetings/myOnlineMeetings";
    request = new RestRequest(onlinemeetingURL, Method.POST);
    request.AddHeader("Accept", "application/json");
    request.AddHeader("Host", "lynctswebint.Mycompany.com");
    request.AddHeader("expirationTime","1482572914000");
    request.AddHeader("Authorization", String.Format("{0} {1}", applicationTokenType, applicationToken));
    var applicationBody = @"""lobbyBypassForPhoneUsers"" : ""Disabled"",""phoneUserAdmission"" : ""Disabled"",""description"":""{0}"",""subject"":""{1}"",""attendees"":""{2}"",""leaders"":""{3}""";
    request.RequestFormat = DataFormat.Xml;
    request.AddParameter(
        "application/json",
       "{" + string.Format(applicationBody, "This is a test for UCWA meeting creation", "Test UCWA meeting creation", "sip:testonline.lync@Mycompany.com", "sip:lync.test@Mycompany.com") + "}",
        ParameterType.RequestBody);
    ucwaClient.ExecuteAsync(request, this.functionToCall);

没有关于这个错误的更多细节。我使用的是restSharp库

使用UCWA API来安排Lync会议

除了提到的有效负载格式规范不一致之外,您的代码/有效负载包含的错误很少。

例如,expirationTime信息也必须在有效负载体中提供,而不是作为请求头的一部分。此外,参与者领导者应该是数组。

我建议您仔细阅读并实现
文档中的内容。myOnlineMeetings资源

下面的代码片段是不正确的

request.AddParameter(
        "application/json",
       "{" + string.Format(applicationBody, "This is a test for UCWA meeting creation", "Test UCWA meeting creation", "sip:testonline.lync@Mycompany.com", "sip:lync.test@Mycompany.com") + "}",
        ParameterType.RequestBody);

我必须传递数组的参加者和领导人,而我是传递字符串。我做了如下修改,现在工作正常了。

request.AddParameter("application/json", "{'r'n '"attendanceAnnouncementsStatus'":'"Enabled'",'r'n '"description'":'"This is a test for UCWA meeting creation'",'r'n '"subject'":'"Test UCWA meeting creation'",'r'n '"attendees'": ['"sip:testonline.lync@mycompany.com'"],'r'n '"leaders'": ['"sip:lync.test@mycompany.com'"]'r'n }", ParameterType.RequestBody)