Question

Fax attachments download using C#

  • 24 September 2018
  • 5 replies
  • 1498 views

Could you help me with RingCentral Fax API.

I need C# code to download fax attachments . I'am using sandbox account and I found this API in APi Explorer /restapi/v1.0/account/{accountId}/extension/{extensionId}/message-store/{messageId}/content/{attachmentId}


5 replies

Sample C# code: https://github.com/ringcentral/ringcentral-csharp-client/blob/master/RingCentral.Test/BinaryTest.cs#...
Hi, I have another problem. Filename is always null. I need filename with extension.
In this case filename is NULL

rc = new RestClient(RingCentralAppKey, RingCentralAppSecretKey,false);
                await rc.Authorize(RingCentralUsername, RingCentralExtension, RingCentralPassword);
                var account = rc.Restapi().Account();
                var extension = account.Extension();
              
                var response = await extension.MessageStore().List();
                var messages = response.records;
                // fax
                var message = messages.Where(m => m.type == "Fax" && m.messageStatus != "SendingFailed" && m.attachments != null && m.attachments.Length > 0);
                foreach (var m in message)
                {
                    var messageResponse = await extension.MessageStore(m.id).Content(m.attachments[0].id).Get();
                    var content = messageResponse.data;
                   
                    var file = new DocumentModel
                    {
                        FileName = m.attachments[0].filename,//this is null
                        FileContent = content
                    };
                }
 
I think all of them are of ".pdf" extension, regardless of their original format.  This is because before sending the fax, RingCentral server will pre-render the content to PDF format. So the receiver side always get PDF files.

Let me double check though.
Please check for filename also.
When I inspect the attachment:

{ id: 1111,
      uri:
       'https://media.devtest.ringcentral.com/restapi/v1.0/account/111/extension/222/message-sto...',
      type: 'RenderedDocument',
      contentType: 'application/pdf' }

You can see that type is RenderedDocument

The attachment is not the original file from the fax sender.  And it might be the result of the merging of multiple files.

There is no name for the attachment file. We only know that it's a PDF.

Reply