hashtag
hashtag

Reputation: 63

How to view/download the sent fax using RingCentral Fax API C#

Could you help me with RingCentral Fax API. I need C# code to download attachments sent via Fax. I'm using sandbox account and I found this API in API Explorer:

/restapi/v1.0/account/{accountId}/extension/{extensionId}/message-store/{messageId}/content/{attachmentId}

Upvotes: 2

Views: 437

Answers (2)

satya
satya

Reputation: 1

You can Download using WebClient Class. Sample Code For Your Reference.

Code:

WebClient client = new WebClient();
client.Headers.Add("Authorization", "Bearer Access_Token");
File.WriteAllBytes(@"Path To Download", client.DownloadData(URL));

Note: URL is restapi/v1.0/account/AccountID/extension/extension ID/message-store/Message ID/content/Message ID

Upvotes: 0

Paco Vu
Paco Vu

Reputation: 211

Using the RingCentral C-Sharp SDK you can download the binary content as shown below:

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);

See detailed sample code from here

Upvotes: 2

Related Questions