Welcome! Log In Create A New Profile

Advanced

Office 365 OR Google Calendar Integration

Posted by MediOffice 
Office 365 OR Google Calendar Integration
February 06, 2022 12:59PM
Anyone got any experience or examples of using WebDev to create, update, delete calendar entries in Office 365 or Google Calendars?

Thanks

Gavin
pao
Re: Office 365 OR Google Calendar Integration
February 07, 2022 10:06AM
We have done it in WINDEV22 using OAUTH2 for authentication, the Graph API for MS and Calendar API for google
[docs.microsoft.com]
[developers.google.com]

All is done using httpRequest and httpResponse and httpsend function.
Sample code (very simple one) to create one event:
//GOOGLE
res_var is Variant

wbody is string=[
{
"summary": "Ferias varios dias",
"description": "Ferias varios",
"start": {
"date": "2019-05-31",
"timeZone": "Europe/London"
},
"end": {
"date": "2019-06-05",
"timeZone": "Europe/London"
}
}
]

HTTPTimeOut(600000)
HTTP.IgnoreError = httpIgnoreInvalidCertificate+httpIgnoreInvalidCertificateName+httpIgnoreExpiredCertificate+httpIgnoreRedirectToHTTP+httpIgnoreRedirectToHTTPS
cMyRequest is httpRequest
cMyRequest..URL = "[www.googleapis.com];
cMyRequest..Header["Authorization"]="Bearer "+p_access_token
cMyRequest..Content=wbody
cMyRequest..ContentType="application/json"
cMyRequest..IgnoreError = httpIgnoreInvalidCertificate+httpIgnoreInvalidCertificateName+httpIgnoreExpiredCertificate+httpIgnoreRedirectToHTTP+httpIgnoreRedirectToHTTPS
cMyRequest..Method=httpPost
cMyResponse is httpResponse = HTTPSend(cMyRequest)
IF ErrorOccurred THEN
Error("Erro na criação de eventyo",ErrorInfo(errFullDetails))
END


WHEN EXCEPTION IN
res_var=JSONToVariant(cMyResponse..Content)
DO
Info("não é um JSON valido",cMyResponse..Content)
RETURN

END
IF res_var.error..Exist THEN
Info("erro token criar evento",cMyResponse..Content)
RETURN
END


MOSTRA_RESULTADO=VariantToJSON(res_var,psdFormatting)
MyWindow..Plane=3
WHILE MyWindow..Plane<>2
Multitask(-1)
CONTINUE
END

//MS
//
res_var is Variant

wbody is string=[
{
"subject": "Ferias varios dias",
"isReminderOn": "False",
"isAllDay": "True",
"hasAttachments": "false",
"responseRequested": "False",
"categories": ["FERIAS"],
"showAs": "oof",
"body": {
"contentType": "HTML",
"content": "Ferias xxx"
},
"start": {
"dateTime": "2019-05-31T00:00:00",
"timeZone": "Europe/London"
},
"end": {
"dateTime": "2019-06-05T00:00:00",
"timeZone": "Europe/London"
}
}
]

HTTPTimeOut(600000)
HTTP.IgnoreError = httpIgnoreInvalidCertificate+httpIgnoreInvalidCertificateName+httpIgnoreExpiredCertificate+httpIgnoreRedirectToHTTP+httpIgnoreRedirectToHTTPS

cMyRequest is httpRequest
cMyRequest..URL = "[graph.microsoft.com];
cMyRequest..Header["Authorization"]="Bearer "+p_access_token
cMyRequest..Content=wbody
cMyRequest..ContentType="application/json"
cMyRequest..IgnoreError = httpIgnoreInvalidCertificate+httpIgnoreInvalidCertificateName+httpIgnoreExpiredCertificate+httpIgnoreRedirectToHTTP+httpIgnoreRedirectToHTTPS
cMyRequest..Method=httpPost
cMyResponse is httpResponse = HTTPSend(cMyRequest)
IF ErrorOccurred THEN
Error("Erro na criação de eventyo",ErrorInfo(errFullDetails))
END


WHEN EXCEPTION IN
res_var=JSONToVariant(cMyResponse..Content)
DO
Info("não é um JSON valido",cMyResponse..Content)
RETURN
END
IF res_var.error..Exist THEN
Info("erro token criar evento",cMyResponse..Content)
RETURN
END

IF cMyResponse..StatusCode="201" THEN
MOSTRA_RESULTADO=VariantToJSON(res_var,psdFormatting)
MyWindow..Plane=3
WHILE MyWindow..Plane<>2
Multitask(-1)
CONTINUE
END
ELSE
Info("erro criar evento",cMyResponse..Content)
END

Regards

Paulo Oliveira
Re: Office 365 OR Google Calendar Integration
February 07, 2022 07:36PM
Super! Thank you very much Pao
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: