News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
Fax API - Keeps failing with attachment using Javascript SDK from base64
Tags: fax, rest api
Sep 30, 2022 at 10:16am   •   1 replies  •  0 likes
Customer Support 1

Hi - I've tried all kinds of ways to get the SDK working. If i use the code in the template with fs.createreadstream - it works fine reading from a file.


i'm trying to upload reading from a base64 string. I've tried converting to a buffer / string - all kinds of things. The API call completes, but the status is failed in the dashboard and I don't know why it failed as there isn't further logging. Beating my head against the wall on this one. Any help would be hugely appreciated.

1 Answer
answered on Sep 30, 2022 at 11:22am  

To send a fax with attachment is a base64 string using the RingCentral Node JS SDK, try this.

async function sendFax() {
  try{
    var endpoint = "/restapi/v1.0/account/~/extension/~/fax"
    var FormData = require('form-data');
    formData = new FormData();
    var body = {
      to: [{'phoneNumber': "RECIPIENT-NUMBER"}],
      faxResolution: 'High',
    }

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

    var base64Data = "...JsHpb9we8DAfN9fUY+h9OL9b4NKMvqwAAAABJRU5ErkJggg=="
    var bufferValue = Buffer.from(base64Data,"base64");
    formData.append('attachment', bufferValue, 'image.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.message)
  }
}

BTW, there is a current issue with receiving fax attachment in the sandbox environment. You will only get the cover page, no attachment pages but the fax status should be "Sent" though.


 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us