微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Indy 10 in Lazarus RingCentral API RingOut TIdHTTP

如何解决Indy 10 in Lazarus RingCentral API RingOut TIdHTTP

拉撒路1.8.4
Indy 10(2020年3月)
Windows Server 2016

我正在尝试为我在Lazarus中建立的联系人列表构建一个小的“拨号程序”模块。经过几个月的摸索,我终于能够将所有RingCentral API设置转换为Postman,然后转换为Indy HTTP设置,以完成令牌的获取。该部分工作可靠。但是,我无法执行RingOut API。我总是找不到404。 RingCentral在其文档中提供的其他编程语言中的示例无法很好地转换为Indy。

if htpCall.Connected then
  htpCall.Request.Connection := 'close';  // Close the socket after using it to obtain the token
htpCall.Request.Clear;

htpCall.Request.Accept := 'application/json';
htpCall.Request.ContentType := 'application/json';
htpCall.Request.Username := '<redacted>';   // Client ID
htpCall.Request.Password := '<redacted>';   //  Client Secret
htpCall.Request.CustomHeaders.Clear;
htpCall.Request.CustomHeaders.FoldLines := False;
htpCall.Request.BasicAuthentication := False;
htpCall.Request.CustomHeaders.AddValue('Authorization','Bearer ' + acc_tkn);

prms_lst.Add('from=<redacted>');
prms_lst.Add('to=<redacted>');
prms_lst.Add('callerId=<redacted>');
prms_lst.Add('country=Canada');
prms_lst.Add('playPrompt=true');

// Remove the text ".devtest" for the production version of your code,and replace the phone account with the real main phone number
htpCall.Post('https://platform.devtest.ringcentral.com/restapi/v1.0/account/<redacted>/extension/101/ring-out',prms_lst);

更新:

如果我将TIdHTTP保持打开状态,然后运行上面的代码,则会收到其他错误

已发送:

POST /restapi/v1.0/account//extension/101/ring-out HTTP/1.1
Content-Type: application/json
Content-Length: 82
Authorization: Basic 
Host: platform.devtest.ringcentral.com
Accept: application/json
User-Agent: Mozilla/3.0 (compatible; Indy Library)


from=&to=&callerId=&country=Canada&playPrompt=true

Rcvd:

HTTP/1.1 401 Unauthorized
Server: Nginx
Date: Tue,25 Aug 2020 01:50:24 GMT
Content-Type: application/json
Content-Length: 175
Connection: keep-alive
WWW-Authenticate: Bearer realm="RingCentral REST API"
RCRequestId: 57c97008-e675-11ea-87cf-005056bb81b6

{
  "errorCode" : "AGW-402","message" : "Invalid Authorization header","errors" : [ {
    "errorCode" : "AGW-402","message" : "Invalid Authorization header"
  } ]
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。