I am using a backend server and I want to upload attachments to “Issue” doctype by sending a POST
request from the backend.
The backend api endpoint looks like this
app.post("/api/v1/issues", async (req: Request, res: Response) => {
try {
const issue_data = req.body;
// const { attachments }: { attachments?: string[] } = issue_data;
config.data = issue_data;
config.url = `http://localhost:8080/api/resource/Issue`;
config.method = "post";
const response = await axios.request(config);
res.json(response.data);
} catch (error: any) {
console.log(error.message);
res.status(500).json({ message: "An error occurred while creating issue." });
}
});
And the curl request from client app looks like this
curl --location 'http://localhost:3000/api/v1/issues' \
--header 'Content-Type: application/json' \
--header 'Cookie: authorization cookie here' \
--data-raw '{
"subject": "New Problem",
"doctype": "Issue",
"naming_series": "ISS-.YYYY.-",
"customer": "Palmer Productions Ltd.",
"raised_by": "new@example.com",
"description": "oiashdoiahdoiahsd",
"attachments": [
"https://google.com",
"https://mail.google.com"
]
}
'
What can I do to upload the attachments on the form?