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

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now