SOLVED. See next post for code.
I have succesfully added a "quick event", but I am having difficulties when I try to add an "event" to Google Calendar, as I am getting the 400 error message: "Missing end time."
I suspect that maybe the nested objects "start" and "end" are not correctly sent with the request.
I have also tried using a map object and JSONGenerator, instead of putting my values directly to the HTTP Request, but I am getting the same error.
Could someone please explain how to create this request?
Thanks in advance for your help.
Please find my code below:
I have succesfully added a "quick event", but I am having difficulties when I try to add an "event" to Google Calendar, as I am getting the 400 error message: "Missing end time."
I suspect that maybe the nested objects "start" and "end" are not correctly sent with the request.
I have also tried using a map object and JSONGenerator, instead of putting my values directly to the HTTP Request, but I am getting the same error.
Could someone please explain how to create this request?
Thanks in advance for your help.
Please find my code below:
B4X:
Sub add_event
oauth2.GetAccessToken
Wait For OAuth2_AccessTokenAvailable (Success As Boolean, Token As String)
If Success = False Then
Log("Error accessing account.")
Return
End If
Dim Summary, StartDateTime, EndDateTime As String
Dim BaseURL As String = "https://www.googleapis.com/calendar/v3/calendars/primary/events"
Summary="My Summary"
StartDateTime = "2019-04-19T12:00:00-07:00"
EndDateTime = "2019-04-19T13:00:00-07:00"
Dim j As HttpJob
j.Initialize("", Me)
j.PostString($"${BaseURL}/?access_token=${Token}"$ & " &summary='" & Summary & "'&start.dateTime='" & StartDateTime & "'&end.dateTime='" & EndDateTime & "'", "")
j.GetRequest.SetContentType("application/json")
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
Else
Log(j.ErrorMessage)
Log("Online data not available.")
End If
j.Release
End Sub
Last edited: