My POST request is failing with a 'Request with GET/HEAD method cannot have body' error

My POST request is failing with a 'Request with GET/HEAD method cannot have body' error

I am trying to use Zoho Creator's ADD RECORDS DATA API (https://www.zoho.com/creator/help/api/v2/add-records.html)

And here's the URL to help you understand my issue. The URL below will show you a JSON of all the variables involved before I run the POST method.

https://vp-expo-node-server.herokuapp.com/eticket/

This above link will show you the result of this controller


exports.addOneExhibitorToCreator = async function(req, res, next) {
  try {
    const token = await getAccessToken();
    const url = process.env.ZOHO_CREATOR_FORM_URL + "/Add_Organisation";
    // const organisation = req.body;
    const organisation = {
      data: {
        isActive: true,
        Organisation_Name: "Test With Alim",
        Type: "Exhibitor",
        Short_Name: "test",
        Email: "test@fourplusmedia.com",
      },
    };

    const options = {
      Method: "POST",
      Headers: {
        "Content-Type": "application/json",
        Authorization: "Zoho-oauthtoken " + token,
      },
      body: JSON.stringify(organisation),
    };

    const functionForResponse = "const response = await fetch(url, options);";

    // const response = await fetch(url, options);
    // const data = await response.json();

    res.status(200).json({
      status: "success",
      token,
      options,
      url,
      organisation,
      functionForResponse,
    });
  } catch (err) {
    console.log(err);
    res.status(500).json({
      err,
    });
  }
};


When I uncomment these 2 lines in the above controller Website

    const response = await fetch(url, options);
    const data = await response.json();

I get this result

https://vp-expo-node-server.herokuapp.com/eticket/response

As I don't know how to display the error on the browser I tried to console.log it and I got this error in the console

TypeError: Request with GET/HEAD method cannot have body
    at new Request (/Applications/MAMP/htdocs/vp-expo-node-server/node_modules/node-fetch/lib/index.js:1199:10)
    at /Applications/MAMP/htdocs/vp-expo-node-server/node_modules/node-fetch/lib/index.js:1409:19
    at new Promise ()
    at fetch (/Applications/MAMP/htdocs/vp-expo-node-server/node_modules/node-fetch/lib/index.js:1407:9)
    at exports.addOneExhibitorToCreatorResponse (/Applications/MAMP/htdocs/vp-expo-node-server/controllers/eticketController.js:82:28)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

And I can confirm that the this line in the console.log

    at exports.addOneExhibitorToCreatorResponse (/Applications/MAMP/htdocs/vp-expo-node-server/controllers/eticketController.js:82:28)

points to the uncommented lines...

So there's something wrong I am doing in those 2 lines.. but according to me it's the right way to send a POST request.. and I have no clue how a POST request can get a Request with GET/HEAD method cannot have body error.

Any help would be appreciated. I've double checked it and I've even asked Zoho for help (they mentioned as it's a client side thing they couldn't do much to help)






                            Zoho Desk Resources

                            • Desk Community Learning Series


                            • Digest


                            • Functions


                            • Meetups


                            • Kbase


                            • Resources


                            • Glossary


                            • Desk Marketplace


                            • MVP Corner


                            • Word of the Day



                                Zoho Marketing Automation
                                        • Sticky Posts

                                        • How to Add Users to your Organization in ZohoMail?

                                          A better clarity so you can create other users to start using Zoho Mail. You can directly Add Users from the Control Panel to your Organization. You can invite users with the existing email address. If the person (user) already uses ZohoCRM, then you can import users from Zoho CRM. You can also import them using a .csv file. (if you are planning to add them in Bulk)  In this topic, We will be discussing on how to Add and Invite users only.  The Import options are self explanatory. ____________________________________________________________________________________________________________


                                        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 WorkDrive Resources



                                                                  Zoho Campaigns Resources

                                                                    Zoho CRM Resources

                                                                    • CRM Community Learning Series

                                                                      CRM Community Learning Series


                                                                    • Tips

                                                                      Tips

                                                                    • 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