I’m trying to add an event to a Google Calendar using the Google API V3. I’m not using any of Google’s libraries so I’m really baffled as to how to do this. Google’s documentation tells me that I need to send an “Events Resource” in the request body. I think I’ve built a valid JSON “string” but I have no idea how to properly prepare it and send it in the so-called “request body”. What confuses me is the way that string values are wrapped in quotes and non-string values are not. Does this mean that I’ll need to wrap the entire thing as a string and double/quadruple quote each double quote?
Here’s the JSON I’ve written but I haven’t figure out yet how to pass this to Google so I haven’t been able to test it:
{
"kind": "calendar#event",
"start": {
"dateTime": 04/10/2012 08:00 AM
},
"end": {
"dateTime": 04/10/2012 08:00 AM
},
"attendees": [
{
"email": "myemailaddress@gmail.com",
"displayName": "My Name",
"organizer": True,
"self": True
}
],
"reminders": {
"useDefault": True
}
}
I do have a VBJSON code module installed in my Access/VBA Database. I see a function in there called StringToJSON which returns a string. I’m still baffled. When I pass this JSON to Google, will it merely be one big string value within my code?
OK, so I finally figured out how to build and pass my JSON string. I’m using VBJSON to build the JSON string. Please remember that JSON is case sensitive (or at least Google interprets it case sensitive). A pair with the key dateTime is not the same as a pair with the key datetime and Google will reject the latter.
The unprettified output is this:
And then here’s how you submit it to Google using V3 of the Google Calendar API. In V3 you have to use OAuth2.0 so you need to have a valid Access Token to append to your URL as shown below. You’ll also need to know your CalendarID which is usually your email address URL encoded. For example, your calendarid will look like this: john.doe%40gmail.com