question

zgrada-zgrada11937 avatar image
zgrada-zgrada11937 asked Tyler Liu answered

Fax attachments download using C#

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}

sdk
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image
Tyler Liu answered
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

zgrada-zgrada11937 avatar image
zgrada-zgrada11937 answered
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
                    };
                }
 
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image
Tyler Liu answered
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.
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

zgrada-zgrada11937 avatar image
zgrada-zgrada11937 answered Tyler Liu commented
Please check for filename also.
1 comment
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image Tyler Liu ♦ commented ·
If what I said above is true, there won't be a reasonable filename.

Because you might send multiple files in a single fax, and those files are merged and rendered to a single pdf file. In such case, what is the filename?  It could be whatever.pdf  because there isn't a one-one mapping from original files to pdf file anyway.
0 Likes 0 ·
Tyler Liu avatar image
Tyler Liu answered
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.
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys