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.