I am trying to make a POST to a Google Calendar API and I need my POST in the following format:
Here is the ZOHO Creator code that I am using:
Map_for_Calendar_API = map();
Map_for_Calendar_API.put("summary", "Trial Event");
Map_for_EndDate = map();
Map_for_EndDate.put("dateTime", ("2014-04-19T17:30:00.000+05:30"));
Map_for_Calendar_API.put("end", Map_for_EndDate);
Map_for_StartDate = map();
Map_for_StartDate.put("dateTime", ("2014-04-19T16:00:00.000+05:30"));
Map_for_Calendar_API.put("start", Map_for_StartDate);
Header_Map = map();
Header_Map.put("Content-Type", "application/json");
Header_Map.put("
Authorization
", "
Bearer MyToken
MyToken
MyToken
MyToken
MyToken
");
Google_Calender_Event_Post_Variable = postUrl("https://www.googleapis.com/calendar/v3/calendars/someone@gmail.com/events?key=<myKey>, Map_for_Calendar_API.toString(), Header_Map, false);
However, I am not getting the JSON formatted correctly.
Here is what my request body ends up like when the POST is fired from ZOHO Creator:
{"summary":"Trial Event","start":"{dateTime=2014-04-19T16:00:00.000+05:30}","end":"{dateTime=2014-04-19T17:30:00.000+05:30}"}
Below is the expected format (observe carefully the quotes, linebreaks don't matter in JSON):
{
"end": {
"dateTime":
"2014-04-19T17:30:00.000+05:30"
},
"start": {
"dateTime":
"2014-04-19T16:00:00.000+05:30"
},
"summary":
"Trial Event"
}
It seems like Zoho Creator cannot convert a nested Map to a proper JSON.
Is there a workround that anyone as tried when POST ing a nested map structure in JSON format in a POST.