Hello,
I am having trouble getting the from_email parameter to work when using the the Freshdesk reply API from here: Freshdesk
When I use just the body parameter by itself, it goes through perfectly fine, but when I use the body parameter in conjunction with the from_email parameter, it doesn’t go through at all.
Below is my code so far, can anyone help me and see where I am going wrong?
import base64 from 'base-64'
const reply = async ( req, res) => {
let reply = req.query.reply;
let id = req.query.id;
let data = {
"from_email": "matthew.gadd@email.com",
"body": reply,
}
try {
const response = await fetch(
"https://website.freshdesk.com/api/v2/tickets/" + id + "/reply",
{
body: JSON.stringify(data),
headers: {
'Authorization': 'Basic ' + base64.encode("apikey:X"),
"Content-Type": "application/json; charset=utf8"
},
method: 'POST'
}
);
console.log(response.headers)
if (response.status >= 400) {
return res.status(400).json({
error: 'There was an error'
});
}
return res.status(200).json({ status: 'ok' });
} catch (error) {
return res.status(500).json({
error: 'There was an error'
});
}
};
export default reply;