Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3663

delphi google calendar Api event insert

$
0
0

I am trying to insert an event into my google calendar using the delphi REST controls.

This is the code so far:

procedure TForm1.TestGoogleRestParams;var  i: Integer;  jsonObjEventResource,jsonObjStart,jsonObjEnd: TJSONObject;begin  try    jsonObjEventResource:=TJSONObject.Create();    jsonObjStart:=TJSONObject.Create();    jsonObjEnd:=TJSONObject.Create();    jsonObjEventResource.AddPair(TJSONPair.Create('summary','test'));    jsonObjEventResource.AddPair(TJSONPair.Create('description','Testing'));    jsonObjEventResource.AddPair(TJSONPair.Create('id',LowerCase('06824945162F4204BFDC041AE1BBAE85')));    jsonObjStart.AddPair(TJSONPair.Create('date',FormatDateTime('yyyy-mm-dd',Now)));    jsonObjEventResource.AddPair(TJSONPair.Create('start',jsonObjStart));    jsonObjEnd.AddPair(TJSONPair.Create('date',FormatDateTime('yyyy-mm-dd',Now)));    jsonObjEventResource.AddPair(TJSONPair.Create('end',jsonObjEnd));    jsonObjEventResource.AddPair(TJSONPair.Create('guestsCanInviteOthers',TJSONBool. Create(false)));    jsonObjEventResource.AddPair(TJSONPair.Create('visibility','private'));    mem_Test.Lines.Add(TJson.Format(jsonObjEventResource));    //mem_Test.Lines.Add(jsonObjEventResource.ToJSON);    RESTRequest.Method := TRESTRequestMethod.rmPOST;    RESTRequest.Body.ClearBody;    RESTRequest.AddBody(jsonObjEventResource);    RESTRequest.Execute;  finally    //jsonObjEventResource.Free;    //jsonObjStart.Free;    //jsonObjEnd.Free;  end;end;

The Scope I am using is: https://www.googleapis.com/auth/calendar.
BaseURL : https://www.googleapis.com/calendar/v3
ResourceURI : calendars/primary/events

I do get an access token and a refresh token but I cannot Post the Request. This is the error i recieve:

{"error":  {"errors":    [            {"domain":"global","reason":"required","message":"Login Required","locationType":"header","location":"Authorization"      }    ],"code":401,"message":"Login Required"  }}

With the following uri: https://www.googleapis.com/calendar/v3/calendars/primary/events

How can i fix this?

If I don't call this method and just call RESTRequest.Execute; I get a list of all my existing events.


Viewing all articles
Browse latest Browse all 3663

Trending Articles