Help needed with multipart/form-data POST rest api request

Hi @weweb-team and other experts,

I am not sure how to create a request for this api. I am trying to use zoho calendar api which requires to perform a POST request using parameters defined in its documentation: POST - Create new event

The problem is that the request data should go in json something like this:

{
“eventdata”: [
{
“enable_eventmanagement”: false,
“role”: “organizer”,
“color”: “”,
“calid”: “2886111000000034003”,
“has_attachment”: false,
“title”: “New Event”,
“calendar_alarm”: false,
“duration”: “90000000”,
“uid”: “78df440494704a9586c69d669e51c7a0@zoho.com”,
“rrule”: “FREQ=YEARLY;INTERVAL=1;BYMONTH=7;BYMONTHDAY=7;COUNT=10”,
“createdby”: “user@zylker.com”,
“etype”: “EVENT”,
“id”: “2886111000000034007”,
“dateandtime”: {
“timezone”: “Asia/Kolkata”,
“start”: “20210307T110000+0530”,
“end”: “20210308T120000+0530”
},
“lastmodifiedtime”: “20210209T141436Z”,
“isprivate”: false,
“createdtime”: “20210209T141436Z”,
“attRSVPNotifyType”: 0,
“estatus”: “added”,
“organizer”: “user@zylker.com”,
“isallday”: false,
“transparency”: 0,
“modifiedby”: “user@zylker.com”,
“etag”: “1612880076006”,
“caluid”: “8b6b8aa9114b4de8a22f1136e648ee70”,
“multiday”: true
}
]
}

When I use the parameters using weweb, I end up with a request like this:

    {
        "enable_eventmanagement": false,
        "role": "organizer",
        "color": "",
        "calid": "2886111000000034003",
        "has_attachment": false,
        "title": "New Event",
        "calendar_alarm": false,
        "duration": "90000000",
        "uid": "78df440494704a9586c69d669e51c7a0@zoho.com",
        "rrule": "FREQ=YEARLY;INTERVAL=1;BYMONTH=7;BYMONTHDAY=7;COUNT=10",
        "createdby": "user@zylker.com",
        "etype": "EVENT",
        "id": "2886111000000034007",
        "dateandtime": {
            "timezone": "Asia/Kolkata",
            "start": "20210307T110000+0530",
            "end": "20210308T120000+0530"
        },
        "lastmodifiedtime": "20210209T141436Z",
        "isprivate": false,
        "createdtime": "20210209T141436Z",
        "attRSVPNotifyType": 0,
        "estatus": "added",
        "organizer": "user@zylker.com",
        "isallday": false,
        "transparency": 0,
        "modifiedby": "user@zylker.com",
        "etag": "1612880076006",
        "caluid": "8b6b8aa9114b4de8a22f1136e648ee70",
        "multiday": true
    }

So I get an error that eventdata is missing.

Any pointers how can I create a request which will work with this api?

This is way beyond my understanding.

You can create the body of the request with a javascript action:

  • create an object with the body of the request and transform it into json
const data = {
  eventdata: [
    {
      enable_eventmanagement: false,
      role: "organizer",
      color: "",
      // any other parameter
    },
  ],
};

return JSON.stringify(data);

Thanks @dorilama I had tried similar approach (I basically copy pasted a request in the body as opposed to making it dynamic to test it out). But it gives similar error.
I am sure it is a format issue.

Same issues was discussed on the Zoho forum: https://help.zoho.com/portal/en/community/topic/cannot-create-calendar-via-api

And a user posted a PHP solution (see line 76). But I am unable to make it work.

Can you share the body of the request you make and the error that you get?

I think there is a misunderstanding since you first post: from the docs it looks like you the request must be with an empty body and a single parameter name d eventdata as query string.

It looks like this parameter must be a json object with all the other parameters specified.

Assuming you use a javascript action to create the json object you can try something like this:

const data = {
  enable_eventmanagement: false,
  role: "organizer",
  color: "",
  // any other parameter
};
return JSON.stringify(data);

Oh, I tried that as well. Let me go back to that, I can send you exact error.

Yeah. I get a 400 bad request error.

Screenshot 2022-12-08 at 1.14.23 PM

You may want to share the full setup of your request or this is just guessing

Sure. How can I do that?

take a screenshot of the editor with the api request
just cover private data before uploading

Adding screenshots here. Please let me know if there are any other views which are needed.

This is the most logical setup. The first is creating the json body.

Now, the API request.

What you just posted is completely different from what I suggested

Check this post and try the example I posted.

According to the docs eventdata is not an array, the request is without a body and eventdata is passed as query string

The screenshots for the second setup you suggested are here:

Have you tried with just the sample data of the docs to check that is not a problem of some other parameter?

{
  "title": "New Event",
  "rrule": "FREQ=YEARLY;INTERVAL=1;BYMONTH=7;BYMONTHDAY=7;COUNT=10",
  "dateandtime": {
    "start": "20210307T110000+0530",
    "end": "20210308T120000+0530",
    "timezone": "Asia/Kolkata"
  }
}

Does it works if you send the request using the sample url from the docs?
https://calendar.zoho.com/api/v1/calendars/8b6b8aa9114b4de8a22f1136e648ee70/events?eventdata={"title":"New Event","rrule": "FREQ=YEARLY;INTERVAL=1;BYMONTH=7;BYMONTHDAY=7;COUNT=10","dateandtime": {"start": "20210307T110000+0530","end": "20210308T120000+0530","timezone": "Asia/Kolkata"}}
just change your calendar id and add the auth and see if it works

Sorry I was away. Just trying these now.

@dorilama I tried a few ways you suggested and I was not able to make it work. I placed a support request with zoho team and it seems to be an issue on their end. They expect a fix by end of the week. I wanted to keep you updated.

1 Like

Strange issue. Thanks for the update :slight_smile: