Creates a new calendar. (i.e. Adds an entry to the user's calendar list.)
var os = require('os');
if (os.platform() == 'win32') {
var chilkat = require('chilkat_node6_win32');
} else if (os.platform() == 'linux') {
if (os.arch() == 'arm') {
var chilkat = require('chilkat_node6_arm');
} else if (os.arch() == 'x86') {
var chilkat = require('chilkat_node6_linux32');
} else {
var chilkat = require('chilkat_node6_linux64');
}
} else if (os.platform() == 'darwin') {
var chilkat = require('chilkat_node6_macosx');
}
function chilkatExample() {
var rest = new chilkat.Rest();
var success;
// Provide a previously obtained OAuth2 access token.
var oauth2 = new chilkat.OAuth2();
oauth2.AccessToken = "OAUTH2_ACCESS_TOKEN";
rest.SetAuthOAuth2(oauth2);
success = rest.Connect("www.googleapis.com",443,true,true);
if (success !== true) {
console.log(rest.LastErrorText);
return;
}
// The following code creates the JSON request body.
// The JSON created by this code is shown below.
var jsonReq = new chilkat.JsonObject();
jsonReq.UpdateString("summary","test calendar abc");
var sbReq = new chilkat.StringBuilder();
jsonReq.EmitSb(sbReq);
rest.AddHeader("Content-Type","application/json");
var sbJson = new chilkat.StringBuilder();
success = rest.FullRequestSb("POST","/calendar/v3/calendars",sbReq,sbJson);
if (success !== true) {
console.log(rest.LastErrorText);
return;
}
if (rest.ResponseStatusCode !== 200) {
console.log("Received error response code: " + rest.ResponseStatusCode);
console.log("Response body:");
console.log(sbJson.GetAsString());
return;
}
var json = new chilkat.JsonObject();
json.LoadSb(sbJson);
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
var kind;
var etag;
var id;
var summary;
kind = json.StringOf("kind");
etag = json.StringOf("etag");
id = json.StringOf("id");
summary = json.StringOf("summary");
console.log("Example Completed.");
}
chilkatExample();
{
"summary": "test calendar abc"
}
{
"kind": "calendar#calendar",
"etag": "\"BKjXnZpXR6E5ueFWG3UJk-2POYg/jb82ZwCZzTu1P_p3WnVVxDoJTeI\"",
"id": "chilkatcloud.com_he3bfm0ljrl7p427u8vjmg9afo@group.calendar.google.com",
"summary": "test calendar abc"
}