Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(DataFlex) MS Graph Calendar Create Event

Creates a new event in a specified calendar.

For more details, see https://docs.microsoft.com/en-us/graph/api/calendar-post-events?view=graph-rest-1.0

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoHttp
    Variant vJson
Token    Handle hoJsonToken
    Boolean iSuccess
    Variant vJson
    Handle hoJson
    Variant vResp
    Handle hoResp
    String sDisplayName
    String sLocationType
    String sUniqueId
    String sUniqueIdType
    String sStatusResponse
    String sStatusTime
    String sEmailAddressName
    String sEmailAddressAddress
    String sOdataContext
    String sOdataEtag
    String sId
    String sCreatedDateTime
    String sLastModifiedDateTime
    String sChangeKey
    String sOriginalStartTimeZone
    String sOriginalEndTimeZone
    String sICalUId
    String sReminderMinutesBeforeStart
    String sIsReminderOn
    String sHasAttachments
    String sSubject
    String sBodyPreview
    String sImportance
    String sSensitivity
    String sIsAllDay
    String sIsCancelled
    String sIsOrganizer
    String sResponseRequested
    String sSeriesMasterId
    String sShowAs
    String sType
    String sWebLink
    String sOnlineMeetingUrl
    String sRecurrence
    String sResponseStatusResponse
    String sResponseStatusTime
    String sBodyContentType
    String sBodyContent
    String sStartDateTime
    String sStartTimeZone
    String sEndDateTime
    String sEndTimeZone
    String sLocationDisplayName
    String sLocationLocationType
    String sLocationUniqueId
    String sLocationUniqueIdType
    String sOrganizerEmailAddressName
    String sOrganizerEmailAddressAddress
    Integer i
    Integer iCount_i
    String sTemp1
    Integer iTemp1
    Boolean bTemp1

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // Use your previously obtained access token as shown here:
    //    Get Microsoft Graph OAuth2 Access Token with Calendars.ReadWrite scope.

    Get Create (RefClass(cComChilkatJsonObject)) To hoJsonToken
    If (Not(IsComObjectCreated(hoJsonToken))) Begin
        Send CreateComObject of hoJsonToken
    End
    Get ComLoadFile Of hoJsonToken "qa_data/tokens/msGraphCalendar.json" To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoJsonToken To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComStringOf Of hoJsonToken "access_token" To sTemp1
    Set ComAuthToken Of hoHttp To sTemp1

    // Create a JSON body for the HTTP POST
    // Use this online tool to generate the code from sample JSON: 
    // Generate Code to Create JSON

    // {
    //   "subject": "Let's go for lunch",
    //   "body": {
    //     "contentType": "HTML",
    //     "content": "Does mid month work for you?"
    //   },
    //   "start": {
    //       "dateTime": "2019-11-15T12:00:00",
    //       "timeZone": "Pacific Standard Time"
    //   },
    //   "end": {
    //       "dateTime": "2019-11-15T14:00:00",
    //       "timeZone": "Pacific Standard Time"
    //   },
    //   "location":{
    //       "displayName":"Harry's Bar"
    //   },
    //   "attendees": [
    //     {
    //       "emailAddress": {
    //         "address":"adelev@contoso.onmicrosoft.com",
    //         "name": "Adele Vance"
    //       },
    //       "type": "required"
    //     }
    //   ]
    // }

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End
    Get ComUpdateString Of hoJson "subject" "Let's go for lunch" To iSuccess
    Get ComUpdateString Of hoJson "body.contentType" "HTML" To iSuccess
    Get ComUpdateString Of hoJson "body.content" "Does mid month work for you?" To iSuccess
    Get ComUpdateString Of hoJson "start.dateTime" "2019-11-15T12:00:00" To iSuccess
    Get ComUpdateString Of hoJson "start.timeZone" "Pacific Standard Time" To iSuccess
    Get ComUpdateString Of hoJson "end.dateTime" "2019-11-15T14:00:00" To iSuccess
    Get ComUpdateString Of hoJson "end.timeZone" "Pacific Standard Time" To iSuccess
    Get ComUpdateString Of hoJson "location.displayName" "Harry's Bar" To iSuccess
    Get ComUpdateString Of hoJson "attendees[0].emailAddress.address" "adelev@contoso.onmicrosoft.com" To iSuccess
    Get ComUpdateString Of hoJson "attendees[0].emailAddress.name" "Adele Vance" To iSuccess
    Get ComUpdateString Of hoJson "attendees[0].type" "required" To iSuccess

    // POST the JSON to https://graph.microsoft.com/v1.0/me/calendars/{id}/events
    // This is posting to a calendar in the default calendarGroup.

    // Specify the calendar id
    Get ComSetUrlVar Of hoHttp "id" "AQMkADAwATM0MDAAMS1iNTcwLWI2NTEtMDACLTAwCgBGAAADsVyfxjDU406Ic4X7ill8xAcA5_vF7TKKdE6bGCRqXyl2PQAAAgEGAAAA5_vF7TKKdE6bGCRqXyl2PQAClEpRTgAAAA==" To iSuccess
    Get pvComObject of hoJson to vJson
    Get ComPostJson3 Of hoHttp "https://graph.microsoft.com/v1.0/me/calendars/{$id}/events" "application/json" vJson To vResp
    If (IsComObject(vResp)) Begin
        Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
        Set pvComObject Of hoResp To vResp
    End
    Get ComLastMethodSuccess Of hoHttp To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComBodyStr Of hoResp To sTemp1
    Get ComLoad Of hoJson sTemp1 To iSuccess
    Set ComEmitCompact Of hoJson To False

    Get ComStatusCode Of hoResp To iTemp1
    If (iTemp1 <> 201) Begin
        Get ComEmit Of hoJson To sTemp1
        Showln sTemp1
        Get ComStatusCode Of hoResp To iTemp1
        Showln "Failed, response status code = " iTemp1
        Send Destroy of hoResp
        Procedure_Return
    End

    Send Destroy of hoResp

    Get ComEmit Of hoJson To sTemp1
    Showln sTemp1

    // A sample response:
    // (See code for parsing this response below..)

    // {
    //   "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('admin%40chilkat.io')/calendars('AQMkADAwATM0MDAAMS ... AClEpRTgAAAA%3D%3D')/events/$entity",
    //   "@odata.etag": "W/\"5+vF7TKKdE6bGCRqXyl2PQAClIgmmw==\"",
    //   "id": "AQMkADAwAT ... ApRZ7JkAAAA=",
    //   "createdDateTime": "2019-04-26T14:31:39.8791929Z",
    //   "lastModifiedDateTime": "2019-04-26T14:31:41.2753537Z",
    //   "changeKey": "5+vF7TKKdE6bGCRqXyl2PQAClIgmmw==",
    //   "categories": [
    //   ],
    //   "originalStartTimeZone": "Pacific Standard Time",
    //   "originalEndTimeZone": "Pacific Standard Time",
    //   "iCalUId": "040000008200E00074C5B7101A82E00800000000F05DF1C23CFCD40100000000000000001000000009911D155F71EF42A230FEBFE5F7486A",
    //   "reminderMinutesBeforeStart": 15,
    //   "isReminderOn": true,
    //   "hasAttachments": false,
    //   "subject": "Let's go for lunch",
    //   "bodyPreview": "Does mid month work for you?",
    //   "importance": "normal",
    //   "sensitivity": "normal",
    //   "isAllDay": false,
    //   "isCancelled": false,
    //   "isOrganizer": true,
    //   "responseRequested": true,
    //   "seriesMasterId": null,
    //   "showAs": "busy",
    //   "type": "singleInstance",
    //   "webLink": "https://outlook.live.com/owa/?itemid=AQMkADAwATM0MDAAMS1iNTcwL...pRZ7JkAAAA%3D&exvsurl=1&path=/calendar/item",
    //   "onlineMeetingUrl": null,
    //   "recurrence": null,
    //   "responseStatus": {
    //     "response": "organizer",
    //     "time": "0001-01-01T00:00:00Z"
    //   },
    //   "body": {
    //     "contentType": "html",
    //     "content": "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=us-ascii\">\r\n</head>\r\n<body>\r\nDoes mid month work for you?\r\n</body>\r\n</html>\r\n"
    //   },
    //   "start": {
    //     "dateTime": "2019-11-15T12:00:00.0000000",
    //     "timeZone": "Pacific Standard Time"
    //   },
    //   "end": {
    //     "dateTime": "2019-11-15T14:00:00.0000000",
    //     "timeZone": "Pacific Standard Time"
    //   },
    //   "location": {
    //     "displayName": "Harry's Bar",
    //     "locationType": "default",
    //     "uniqueId": "Harry's Bar",
    //     "uniqueIdType": "private"
    //   },
    //   "locations": [
    //     {
    //       "displayName": "Harry's Bar",
    //       "locationType": "default",
    //       "uniqueId": "Harry's Bar",
    //       "uniqueIdType": "private"
    //     }
    //   ],
    //   "attendees": [
    //     {
    //       "type": "required",
    //       "status": {
    //         "response": "none",
    //         "time": "0001-01-01T00:00:00Z"
    //       },
    //       "emailAddress": {
    //         "name": "Adele Vance",
    //         "address": "adelev@contoso.onmicrosoft.com"
    //       }
    //     }
    //   ],
    //   "organizer": {
    //     "emailAddress": {
    //       "name": "Matt",
    //       "address": "outlook_3A33FCEB9B74CC15@outlook.com"
    //     }
    //   }
    // }
    // 
    // 

    // Use this online tool to generate parsing code from sample JSON: 
    // Generate Parsing Code from JSON

    Get ComStringOf Of hoJson '"@odata.context"' To sOdataContext
    Get ComStringOf Of hoJson '"@odata.etag"' To sOdataEtag
    Get ComStringOf Of hoJson "id" To sId
    Get ComStringOf Of hoJson "createdDateTime" To sCreatedDateTime
    Get ComStringOf Of hoJson "lastModifiedDateTime" To sLastModifiedDateTime
    Get ComStringOf Of hoJson "changeKey" To sChangeKey
    Get ComStringOf Of hoJson "originalStartTimeZone" To sOriginalStartTimeZone
    Get ComStringOf Of hoJson "originalEndTimeZone" To sOriginalEndTimeZone
    Get ComStringOf Of hoJson "iCalUId" To sICalUId
    Get ComIntOf Of hoJson "reminderMinutesBeforeStart" To sReminderMinutesBeforeStart
    Get ComBoolOf Of hoJson "isReminderOn" To sIsReminderOn
    Get ComBoolOf Of hoJson "hasAttachments" To sHasAttachments
    Get ComStringOf Of hoJson "subject" To sSubject
    Get ComStringOf Of hoJson "bodyPreview" To sBodyPreview
    Get ComStringOf Of hoJson "importance" To sImportance
    Get ComStringOf Of hoJson "sensitivity" To sSensitivity
    Get ComBoolOf Of hoJson "isAllDay" To sIsAllDay
    Get ComBoolOf Of hoJson "isCancelled" To sIsCancelled
    Get ComBoolOf Of hoJson "isOrganizer" To sIsOrganizer
    Get ComBoolOf Of hoJson "responseRequested" To sResponseRequested
    Get ComStringOf Of hoJson "seriesMasterId" To sSeriesMasterId
    Get ComStringOf Of hoJson "showAs" To sShowAs
    Get ComStringOf Of hoJson "type" To sType
    Get ComStringOf Of hoJson "webLink" To sWebLink
    Get ComStringOf Of hoJson "onlineMeetingUrl" To sOnlineMeetingUrl
    Get ComStringOf Of hoJson "recurrence" To sRecurrence
    Get ComStringOf Of hoJson "responseStatus.response" To sResponseStatusResponse
    Get ComStringOf Of hoJson "responseStatus.time" To sResponseStatusTime
    Get ComStringOf Of hoJson "body.contentType" To sBodyContentType
    Get ComStringOf Of hoJson "body.content" To sBodyContent
    Get ComStringOf Of hoJson "start.dateTime" To sStartDateTime
    Get ComStringOf Of hoJson "start.timeZone" To sStartTimeZone
    Get ComStringOf Of hoJson "end.dateTime" To sEndDateTime
    Get ComStringOf Of hoJson "end.timeZone" To sEndTimeZone
    Get ComStringOf Of hoJson "location.displayName" To sLocationDisplayName
    Get ComStringOf Of hoJson "location.locationType" To sLocationLocationType
    Get ComStringOf Of hoJson "location.uniqueId" To sLocationUniqueId
    Get ComStringOf Of hoJson "location.uniqueIdType" To sLocationUniqueIdType
    Get ComStringOf Of hoJson "organizer.emailAddress.name" To sOrganizerEmailAddressName
    Get ComStringOf Of hoJson "organizer.emailAddress.address" To sOrganizerEmailAddressAddress
    Move 0 To i
    Get ComSizeOfArray Of hoJson "categories" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        // ...
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJson "locations" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "locations[i].displayName" To sDisplayName
        Get ComStringOf Of hoJson "locations[i].locationType" To sLocationType
        Get ComStringOf Of hoJson "locations[i].uniqueId" To sUniqueId
        Get ComStringOf Of hoJson "locations[i].uniqueIdType" To sUniqueIdType
        Move (i + 1) To i
    Loop

    Move 0 To i
    Get ComSizeOfArray Of hoJson "attendees" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJson To i
        Get ComStringOf Of hoJson "attendees[i].type" To sType
        Get ComStringOf Of hoJson "attendees[i].status.response" To sStatusResponse
        Get ComStringOf Of hoJson "attendees[i].status.time" To sStatusTime
        Get ComStringOf Of hoJson "attendees[i].emailAddress.name" To sEmailAddressName
        Get ComStringOf Of hoJson "attendees[i].emailAddress.address" To sEmailAddressAddress
        Move (i + 1) To i
    Loop

    Showln "Success."


End_Procedure

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.