6500 General Error when uploading files for a comment via the API

6500 General Error when uploading files for a comment via the API

Hello,

I am trying to create a comment for a task via the API, and upload files in the task comment.

When I use Postman, everything works fine, both the comment and files are added.

However, when I use axios in Node.js to send a POST request, I am getting an error. This is the code that I am using:

  1. const url = `https://projectsapi.zoho.eu/restapi/portal/${zoho.username}/projects/${zohoProject}/tasks/${req.body.id}/comments/?content=${req.body.comment}`;

  2. const formData = new FormData();

  3. formData.append('uploaddoc', fs.createReadStream(path.join(__dirname, '..', 'files', 'test.jpg')), { filename: 'test.jpg' });

  4. response = await axios.post(url, formData, {
  5.      headers: {
  6.           Authorization: 'Bearer ' + accessToken,
  7.           'Content-Type': 'multipart/form-data'
  8.      }
  9. });

The response I receive from the API is:
  1. { code: 6500, message: 'General Error' }
It appears that this line in my code:
  1. 'Content-Type': 'multipart/form-data'
is causing the error. When I remove that line, the comment content is submitted correctly, however no file is uploaded.

Any ideas as to what I may be doing wrong?

Thanks