Returns a specified event from a specified calendar.
This example gets an event from the calendar having the ID = "support@chilkatcloud.com", where the event ID equals "35ocdnnjofbtfs6c602uqvdg9u"
CREATE PROCEDURE ChilkatSample
AS
BEGIN
DECLARE @hr int
DECLARE @iTmp0 int
DECLARE @sTmp0 nvarchar(4000)
DECLARE @rest int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Rest', @rest OUT
IF @hr <> 0
BEGIN
PRINT 'Failed to create ActiveX component'
RETURN
END
DECLARE @success int
-- Provide a previously obtained OAuth2 access token.
DECLARE @oauth2 int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.OAuth2', @oauth2 OUT
EXEC sp_OASetProperty @oauth2, 'AccessToken', 'OAUTH2_ACCESS_TOKEN'
EXEC sp_OAMethod @rest, 'SetAuthOAuth2', @success OUT, STR(@oauth2)
EXEC sp_OAMethod @rest, 'Connect', @success OUT, 'www.googleapis.com', 443, 1, 1
IF STR(@success) <> 1
BEGIN
EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @oauth2
RETURN
END
DECLARE @sbJson int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.StringBuilder', @sbJson OUT
EXEC sp_OAMethod @rest, 'FullRequestNoBodySb', @success OUT, 'GET', '/calendar/v3/calendars/support@chilkatcloud.com/events/35ocdnnjofbtfs6c602uqvdg9u', STR(@sbJson)
IF STR(@success) <> 1
BEGIN
EXEC sp_OAGetProperty @rest, 'LastErrorText', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @oauth2
EXEC @hr = sp_OADestroy @sbJson
RETURN
END
EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @iTmp0 OUT
IF @iTmp0 <> 200
BEGIN
EXEC sp_OAGetProperty @rest, 'ResponseStatusCode', @iTmp0 OUT
PRINT 'Received error response code: ' + @iTmp0
PRINT 'Response body:'
EXEC sp_OAMethod @sbJson, 'GetAsString', @sTmp0 OUT
PRINT @sTmp0
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @oauth2
EXEC @hr = sp_OADestroy @sbJson
RETURN
END
DECLARE @json int
EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @json OUT
EXEC sp_OAMethod @json, 'LoadSb', @success OUT, STR(@sbJson)
-- The following code parses the JSON response.
-- A sample JSON response is shown below the sample code.
DECLARE @kind nvarchar(4000)
DECLARE @etag nvarchar(4000)
DECLARE @id nvarchar(4000)
DECLARE @status nvarchar(4000)
DECLARE @htmlLink nvarchar(4000)
DECLARE @created nvarchar(4000)
DECLARE @updated nvarchar(4000)
DECLARE @summary nvarchar(4000)
DECLARE @location nvarchar(4000)
DECLARE @creatorEmail nvarchar(4000)
DECLARE @creatorSelf int
DECLARE @organizerEmail nvarchar(4000)
DECLARE @organizerSelf int
DECLARE @startDateTime nvarchar(4000)
DECLARE @endDateTime nvarchar(4000)
DECLARE @iCalUID nvarchar(4000)
DECLARE @sequence int
DECLARE @hangoutLink nvarchar(4000)
DECLARE @remindersUseDefault int
DECLARE @i int
DECLARE @count_i int
DECLARE @email nvarchar(4000)
DECLARE @responseStatus nvarchar(4000)
DECLARE @organizer int
DECLARE @self int
EXEC sp_OAMethod @json, 'StringOf', @kind OUT, 'kind'
EXEC sp_OAMethod @json, 'StringOf', @etag OUT, 'etag'
EXEC sp_OAMethod @json, 'StringOf', @id OUT, 'id'
EXEC sp_OAMethod @json, 'StringOf', @status OUT, 'status'
EXEC sp_OAMethod @json, 'StringOf', @htmlLink OUT, 'htmlLink'
EXEC sp_OAMethod @json, 'StringOf', @created OUT, 'created'
EXEC sp_OAMethod @json, 'StringOf', @updated OUT, 'updated'
EXEC sp_OAMethod @json, 'StringOf', @summary OUT, 'summary'
EXEC sp_OAMethod @json, 'StringOf', @location OUT, 'location'
EXEC sp_OAMethod @json, 'StringOf', @creatorEmail OUT, 'creator.email'
EXEC sp_OAMethod @json, 'BoolOf', @creatorSelf OUT, 'creator.self'
EXEC sp_OAMethod @json, 'StringOf', @organizerEmail OUT, 'organizer.email'
EXEC sp_OAMethod @json, 'BoolOf', @organizerSelf OUT, 'organizer.self'
EXEC sp_OAMethod @json, 'StringOf', @startDateTime OUT, 'start.dateTime'
EXEC sp_OAMethod @json, 'StringOf', @endDateTime OUT, 'end.dateTime'
EXEC sp_OAMethod @json, 'StringOf', @iCalUID OUT, 'iCalUID'
EXEC sp_OAMethod @json, 'IntOf', @sequence OUT, 'sequence'
EXEC sp_OAMethod @json, 'StringOf', @hangoutLink OUT, 'hangoutLink'
EXEC sp_OAMethod @json, 'BoolOf', @remindersUseDefault OUT, 'reminders.useDefault'
SELECT @i = 0
EXEC sp_OAMethod @json, 'SizeOfArray', @count_i OUT, 'attendees'
WHILE STR(@i) < STR(@count_i)
BEGIN
EXEC sp_OASetProperty @json, 'I', STR(@i)
EXEC sp_OAMethod @json, 'StringOf', @email OUT, 'attendees[i].email'
EXEC sp_OAMethod @json, 'StringOf', @responseStatus OUT, 'attendees[i].responseStatus'
EXEC sp_OAMethod @json, 'BoolOf', @organizer OUT, 'attendees[i].organizer'
EXEC sp_OAMethod @json, 'BoolOf', @self OUT, 'attendees[i].self'
SELECT @i = STR(@i) + 1
END
PRINT 'Example Completed.'
EXEC @hr = sp_OADestroy @rest
EXEC @hr = sp_OADestroy @oauth2
EXEC @hr = sp_OADestroy @sbJson
EXEC @hr = sp_OADestroy @json
END
GO
{
"kind": "calendar#event",
"etag": "\"3020331471326000\"",
"id": "35ocdnnjofbtfs6c602uqvdg9u",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=MzVvY2RubmpvZmJ0ZnM2YzYwMnVxdmRnOXUgc3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t",
"created": "2017-11-08T18:25:38.000Z",
"updated": "2017-11-08T18:28:55.663Z",
"summary": "QXQC",
"location": "Quigley's Irish Pub, 43 E Jefferson Ave, Naperville, IL 60540, USA",
"creator": {
"email": "support@chilkatcloud.com",
"self": true
},
"organizer": {
"email": "support@chilkatcloud.com",
"self": true
},
"start": {
"dateTime": "2017-11-09T20:00:00-06:00"
},
"end": {
"dateTime": "2017-11-09T23:00:00-06:00"
},
"iCalUID": "35ocdnnjofbtfs6c602uqvdg9u@google.com",
"sequence": 0,
"attendees": [
{
"email": "dean@example.com",
"responseStatus": "needsAction"
},
{
"email": "support@chilkatcloud.com",
"organizer": true,
"self": true,
"responseStatus": "accepted"
},
{
"email": "ajay@example.com",
"responseStatus": "needsAction"
},
{
"email": "jim@example.com",
"responseStatus": "needsAction"
},
{
"email": "gilian@example.com",
"responseStatus": "needsAction"
}
],
"hangoutLink": "https://plus.google.com/hangouts/_/chilkatcloud.com/support?hceid=c3VwcG9ydEBjaGlsa2F0Y2xvdWQuY29t.35ocdnnjofbtfs6c602uqvdg9u",
"reminders": {
"useDefault": true
}
}