2

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}

Weihui Guo
  • 3,669
  • 5
  • 34
  • 56
hashtag
  • 63
  • 3
  • 12

2 Answers2

2

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

Paco Vu
  • 211
  • 1
  • 3
0

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

phwt
  • 1,356
  • 1
  • 22
  • 42
satya
  • 1