I am attempting to send a fax with the Vitelity API. I have an API on EC2 that I am calling from the front-end of my React Native app, and that in turn calls the Vitelity API:
const Base64String = async (req, res) => {
let body = req.body;
await postFax(body);
return res.status(200).send({
statusCode: 200,
data: {
...body,
},
});
};
const postFax = async ({
login,
pass,
faxnum,
faxsrc,
recname,
file1,
data1,
}) => {
const VITELITY_URL = `https://api.vitelity.net/fax.php?login=${login}&pass=${pass}&cmd=sendfax&faxnum=${faxnum}&faxsrc=${faxsrc}&recname=${recname}&file1=${file1}&data1=${data1}`;
await fetch(VITELITY_URL, {
method: "POST",
})
.then((res) => res.text())
.then((result) => {
console.log(result);
})
.catch((err) => console.log(err));
};
data1
is Base64 encoded and works with a test image I have that is ~24k characters, however some of the images I’m taking have been upwards of 1.2m characters.
The exact issue I’m getting is 414 Request-URI Too Large
.
This is the front-end:
const sendB64 = b64 => {
let formdata = new FormData();
formdata.append('login', testLogin);
formdata.append('pass', testPass);
formdata.append('cmd', 'sendfax');
formdata.append('faxnum', destinationNumber);
formdata.append('faxsrc', testSenderNumber);
formdata.append('recname', 'Test');
formdata.append('file1', 'testfax.jpg');
formdata.append('data1', b64);
let requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'multipart/form-data',
},
body: formdata,
redirect: 'follow',
};
fetch(API_URL, requestOptions)
.then(response => response.json())
.then(result => {
console.log(result);
showMessage({message: `status: ${result.statusCode}`});
})
.catch(error => console.log('error', error));
};