您能帮我使用RingCentral传真API吗?我需要C#代码才能下载通过传真发送的附件。我正在使用沙盒帐户,并且在API Explorer中找到了该API:
/restapi/v1.0/account/{accountId}/extension/{extensionId}/message-store/{messageId}/content/{attachmentId}
答案 0 :(得分:1)
使用RingCentral C-Sharp SDK,您可以下载二进制内容,如下所示:
RestClient rc = new RestClient("ClientID", "ClientSecret", false);
await rc.Authorize("username", "extensionNumber", "password");
...
var extension = rc.Restapi().Account().Extension();
var messages = response.records;
// fax
var message = messages.Where(m => m.type == "Fax" && m.messageStatus != "SendingFailed" && m.attachments != null && m.attachments.Length > 0).Skip(3).First();
var content = await extension.MessageStore(message.id).Content(message.attachments[0].id).Get();
System.IO.File.WriteAllBytes("filename.ext", content.data);
请参见here
中的详细示例代码答案 1 :(得分:0)
您可以使用WebClient
类进行下载。
示例代码供您参考。
代码:
WebClient client = new WebClient();
client.Headers.Add("Authorization", "Bearer Access_Token");
File.WriteAllBytes(@"Path To Download", client.DownloadData(URL));
注意:URL为restapi/v1.0/account/AccountID/extension/extension ID/message-store/Message ID/content/Message ID