attachmentfaxringcentral

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}


Solution

  • 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