Question

Attaching Multiple Documents for Fax

  • 10 May 2022
  • 3 replies
  • 840 views

Hi folks,

I'm trying to do some automation, but wanted to know if you can attach multiple documents to one request? It allows me to attach one document and fax successfully, but not a second or multiple. For example, this is what I have when writing it in JSON:

Request URL: https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/fax
Request Body:

[
  {
    "control_type": "text",
    "label": "To",
    "name": "to",
    "type": "string",
    "optional": false
  },
  {
    "control_type": "text",
    "label": "Cover index",
    "name": "coverIndex",
    "type": "string",
    "optional": false
  },
  {
    "control_type": "text",
    "label": "Cover page text",
    "name": "coverPageText",
    "type": "string",
    "optional": false
  },
  {
    "name": "attachments",
    "type": "array",
    "optional": false,
    "binary_content": "false",
    "properties": []
  }
]

3 replies

Hi @Sy Hasan
From what I know and what I have tested, you have an option of attaching multiple files/documents to fax but they will get converted to a single pdf file (with multiple pages) and will be sent to the recipient.

What that means is that the recipient will have a single document with multiple pages in it which can represent different documents attached from the source.

Could you share more details about your use case and am I understanding it correctly that you want the recipient to receive multiple documents instead of a single file with multiple pages?

Userlevel 1

Yes, you can send multiple attachments. Just make sure the total of all attachments size must not exceed the max size of 50MB. See this code sample using the RingCentral JS SDK.

async function send_fax() {
  try{
    var endpoint = "/restapi/v1.0/account/~/extension/~/fax"
    var FormData = require('form-data');
    formData = new FormData();
    var body = {
      to: [{'phoneNumber': "RECIPIENT_NUMBER", 'name': "Recipient name" }],
      faxResolution: "High"
      coverPageText: "This is a demo Fax page from Node JS
 
Recipient company
 
Sender name
 
Fax number
 
Subject is subject
 
Comments/Notes"
    }

    formData.append('json', new Buffer.from(JSON.stringify(body)), {
        filename: 'text.json',
        contentType: 'application/json'
        });

    formData.append('attachment', require('fs').createReadStream('first_file.jpg'));
    formData.append('attachment', require('fs').createReadStream('second_file.png'));

    var resp = await platform.post(endpoint, formData)
    var jsonObj = await resp.json()
    console.log("FAX sent. Current status: " + jsonObj.messageStatus + "/" + jsonObj.id)
  }catch(e){
    console.log(e.messsage)
  }
}


See the dev guide documentation for more details

Thanks Phong. However, how would I convert it to the format above? I am using Workato, which is similar to Postman to write this out. Unfortunately, I cannot use any other language format aside from JSON as I posted above. Thanks!

Reply