如何使用 RingCentral Fax view/download 发送传真 API C#
How to view/download the sent fax using RingCentral Fax API C#
你能帮我处理一下 RingCentral Fax API。我需要 C# 代码来下载通过传真发送的附件。我正在使用沙盒帐户,我在 API 资源管理器中找到了这个 API:
/restapi/v1.0/account/{accountId}/extension/{extensionId}/message-store/{messageId}/content/{attachmentId}
使用 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
的详细示例代码
您可以使用 WebClient
Class 下载。
示例代码供您参考。
代码:
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
你能帮我处理一下 RingCentral Fax API。我需要 C# 代码来下载通过传真发送的附件。我正在使用沙盒帐户,我在 API 资源管理器中找到了这个 API:
/restapi/v1.0/account/{accountId}/extension/{extensionId}/message-store/{messageId}/content/{attachmentId}
使用 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
的详细示例代码您可以使用 WebClient
Class 下载。
示例代码供您参考。
代码:
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