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

Unicode C Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(Unicode C) Outlook Calendar Create an Event

See more Outlook Calendar Examples

Create an event in the specified time zone, and assign the event an optional transactionId value.

For more information, see https://docs.microsoft.com/en-us/graph/api/user-post-events?view=graph-rest-1.0&tabs=http#example-1-create-an-event-in-the-specified-time-zone-and-assign-the-event-an-optional-transactionid-value

Chilkat C/C++ Library Downloads

MS Visual C/C++

Linux/CentOS C/C++

Alpine Linux C/C++

MAC OS X C/C++

armhf/aarch64 C/C++

C++ Builder

iOS C/C++

Android C/C++

Solaris C/C++

MinGW C/C++

#include <C_CkHttpW.h>
#include <C_CkJsonObjectW.h>
#include <C_CkCrypt2W.h>
#include <C_CkHttpResponseW.h>

void ChilkatSample(void)
    {
    HCkHttpW http;
    HCkJsonObjectW jsonToken;
    BOOL success;
    HCkJsonObjectW json;
    HCkCrypt2W crypt;
    HCkHttpResponseW resp;
    HCkJsonObjectW jResp;
    const wchar_t *displayName;
    const wchar_t *locationType;
    const wchar_t *uniqueId;
    const wchar_t *uniqueIdType;
    const wchar_t *statusResponse;
    const wchar_t *statusTime;
    const wchar_t *emailAddressName;
    const wchar_t *emailAddressAddress;
    const wchar_t *odata_context;
    const wchar_t *odata_etag;
    const wchar_t *id;
    const wchar_t *createdDateTime;
    const wchar_t *lastModifiedDateTime;
    const wchar_t *changeKey;
    const wchar_t *transactionId;
    const wchar_t *originalStartTimeZone;
    const wchar_t *originalEndTimeZone;
    const wchar_t *iCalUId;
    int reminderMinutesBeforeStart;
    BOOL isReminderOn;
    BOOL hasAttachments;
    const wchar_t *subject;
    const wchar_t *bodyPreview;
    const wchar_t *importance;
    const wchar_t *sensitivity;
    BOOL isAllDay;
    BOOL isCancelled;
    BOOL isOrganizer;
    BOOL responseRequested;
    const wchar_t *seriesMasterId;
    const wchar_t *showAs;
    const wchar_t *v_type;
    const wchar_t *webLink;
    const wchar_t *onlineMeetingUrl;
    BOOL isOnlineMeeting;
    const wchar_t *onlineMeetingProvider;
    BOOL allowNewTimeProposals;
    BOOL isDraft;
    BOOL hideAttendees;
    const wchar_t *recurrence;
    const wchar_t *onlineMeeting;
    const wchar_t *responseStatusResponse;
    const wchar_t *responseStatusTime;
    const wchar_t *bodyContentType;
    const wchar_t *bodyContent;
    const wchar_t *startDateTime;
    const wchar_t *startTimeZone;
    const wchar_t *endDateTime;
    const wchar_t *endTimeZone;
    const wchar_t *locationDisplayName;
    const wchar_t *locationLocationType;
    const wchar_t *locationUniqueId;
    const wchar_t *locationUniqueIdType;
    const wchar_t *organizerEmailAddressName;
    const wchar_t *organizerEmailAddressAddress;
    int i;
    int count_i;

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

    http = CkHttpW_Create();

    // Use your previously obtained access token here: Get Outlook Calendar OAuth2 Access Token (Azure AD v2.0 Endpoint).

    jsonToken = CkJsonObjectW_Create();
    success = CkJsonObjectW_LoadFile(jsonToken,L"qa_data/tokens/outlookCalendar.json");
    if (success == FALSE) {
        wprintf(L"%s\n",CkJsonObjectW_lastErrorText(jsonToken));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(jsonToken);
        return;
    }

    CkHttpW_putAuthToken(http,CkJsonObjectW_stringOf(jsonToken,L"access_token"));

    // Send the following POST:

    // POST https://graph.microsoft.com/v1.0/me/events
    // Prefer: outlook.timezone="Pacific Standard Time"
    // Content-type: application/json
    // 
    // {
    //   "subject": "Let's go for lunch",
    //   "body": {
    //     "contentType": "HTML",
    //     "content": "Does noon work for you?"
    //   },
    //   "start": {
    //       "dateTime": "2017-04-15T12:00:00",
    //       "timeZone": "Pacific Standard Time"
    //   },
    //   "end": {
    //       "dateTime": "2017-04-15T14:00:00",
    //       "timeZone": "Pacific Standard Time"
    //   },
    //   "location":{
    //       "displayName":"Harry's Bar"
    //   },
    //   "attendees": [
    //     {
    //       "emailAddress": {
    //         "address":"samanthab@contoso.onmicrosoft.com",
    //         "name": "Samantha Booth"
    //       },
    //       "type": "required"
    //     }
    //   ],
    //   "allowNewTimeProposals": true,
    //   "transactionId":"7E163156-7762-4BEB-A1C6-729EA81755A7"
    // }

    // Build the JSON body of the POST.
    json = CkJsonObjectW_Create();
    CkJsonObjectW_UpdateString(json,L"subject",L"Let's go for lunch");
    CkJsonObjectW_UpdateString(json,L"body.contentType",L"HTML");
    CkJsonObjectW_UpdateString(json,L"body.content",L"Does noon work for you?");
    CkJsonObjectW_UpdateString(json,L"start.dateTime",L"2021-05-15T12:00:00");
    CkJsonObjectW_UpdateString(json,L"start.timeZone",L"Pacific Standard Time");
    CkJsonObjectW_UpdateString(json,L"end.dateTime",L"2021-05-15T14:00:00");
    CkJsonObjectW_UpdateString(json,L"end.timeZone",L"Pacific Standard Time");
    CkJsonObjectW_UpdateString(json,L"location.displayName",L"Harry's Bar");
    CkJsonObjectW_UpdateString(json,L"attendees[0].emailAddress.address",L"samanthab@contoso.onmicrosoft.com");
    CkJsonObjectW_UpdateString(json,L"attendees[0].emailAddress.name",L"Samantha Booth");
    CkJsonObjectW_UpdateString(json,L"attendees[0].type",L"required");
    CkJsonObjectW_UpdateBool(json,L"allowNewTimeProposals",TRUE);

    // Generate a UUID.
    crypt = CkCrypt2W_Create();
    CkJsonObjectW_UpdateString(json,L"transactionId",CkCrypt2W_generateUuid(crypt));

    // Add the "Prefer" request header.
    CkHttpW_SetRequestHeader(http,L"Prefer",L"outlook.timezone=\"Pacific Standard Time\"");

    // Send the HTTP POST
    resp = CkHttpW_PostJson2(http,L"https://graph.microsoft.com/v1.0/me/events",L"application/json",CkJsonObjectW_emit(json));
    if (CkHttpW_getLastMethodSuccess(http) != TRUE) {
        wprintf(L"%s\n",CkHttpW_lastErrorText(http));
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(jsonToken);
        CkJsonObjectW_Dispose(json);
        CkCrypt2W_Dispose(crypt);
        return;
    }

    wprintf(L"Response status code = %d\n",CkHttpResponseW_getStatusCode(resp));

    jResp = CkJsonObjectW_Create();
    CkJsonObjectW_Load(jResp,CkHttpResponseW_bodyStr(resp));
    CkJsonObjectW_putEmitCompact(jResp,FALSE);
    wprintf(L"%s\n",CkJsonObjectW_emit(jResp));

    CkHttpResponseW_Dispose(resp);

    // The send succeeded if the response status code = 201.
    if (CkHttpResponseW_getStatusCode(resp) != 201) {
        wprintf(L"Failed\n");
        CkHttpW_Dispose(http);
        CkJsonObjectW_Dispose(jsonToken);
        CkJsonObjectW_Dispose(json);
        CkCrypt2W_Dispose(crypt);
        CkJsonObjectW_Dispose(jResp);
        return;
    }

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('user%40example.com')/events/$entity",
    //   "@odata.etag": "W/\"5+vF7TKKdE6bGCRqXyl2PQAEaGQgcw==\"",
    //   "id": "AQMkADAwATM0MDAAMS1iNTcwLWI2NTEtMDACLTAwCgBGAAADsVyfxjDU406Ic4X7ill8xAcA5_vF7TKKdE6bGCRqXyl2PQAAAgENAAAA5_vF7TKKdE6bGCRqXyl2PQAEaDkEcAAAAA==",
    //   "createdDateTime": "2021-04-18T23:38:52.1979259Z",
    //   "lastModifiedDateTime": "2021-04-18T23:38:53.3747647Z",
    //   "changeKey": "5+vF7TKKdE6bGCRqXyl2PQAEaGQgcw==",
    //   "categories": [
    //   ],
    //   "transactionId": "1d12b565-3ca3-4ed8-b3f9-e8a14ac3ac17",
    //   "originalStartTimeZone": "Pacific Standard Time",
    //   "originalEndTimeZone": "Pacific Standard Time",
    //   "iCalUId": "040000008200E00074C5B7101A82E00800000000EF0328FDAB34D7010000000000000000100000004478DD5948382543AFD1B52C25E88C02",
    //   "reminderMinutesBeforeStart": 15,
    //   "isReminderOn": true,
    //   "hasAttachments": false,
    //   "subject": "Let's go for lunch",
    //   "bodyPreview": "Does noon 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=AQMkADAwATM0MDAAMS1iNTcwLWI2NTEtMDACLTAwCgBGAAADsVyfxjDU406Ic4X7ill8xAcA5%2BvF7TKKdE6bGCRqXyl2PQAAAgENAAAA5%2BvF7TKKdE6bGCRqXyl2PQAEaDkEcAAAAA%3D%3D&exvsurl=1&path=/calendar/item",
    //   "onlineMeetingUrl": null,
    //   "isOnlineMeeting": false,
    //   "onlineMeetingProvider": "unknown",
    //   "allowNewTimeProposals": true,
    //   "isDraft": false,
    //   "hideAttendees": false,
    //   "recurrence": null,
    //   "onlineMeeting": 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 noon work for you?\r\n</body>\r\n</html>\r\n"
    //   },
    //   "start": {
    //     "dateTime": "2021-05-15T12:00:00.0000000",
    //     "timeZone": "Pacific Standard Time"
    //   },
    //   "end": {
    //     "dateTime": "2021-05-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": "Samantha Booth",
    //         "address": "samanthab@contoso.onmicrosoft.com"
    //       }
    //     }
    //   ],
    //   "organizer": {
    //     "emailAddress": {
    //       "name": "John Doe",
    //       "address": "outlook_3A33FCEB9B74CC15@outlook.com"
    //     }
    //   }
    // }

    // Sample code for parsing the JSON response...
    // Use the following online tool to generate parsing code from sample JSON:
    // Generate Parsing Code from JSON

    // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat.
    // See this example explaining how this memory should be used: const char * functions.

    odata_context = CkJsonObjectW_stringOf(jResp,L"\"@odata.context\"");
    odata_etag = CkJsonObjectW_stringOf(jResp,L"\"@odata.etag\"");
    id = CkJsonObjectW_stringOf(jResp,L"id");
    createdDateTime = CkJsonObjectW_stringOf(jResp,L"createdDateTime");
    lastModifiedDateTime = CkJsonObjectW_stringOf(jResp,L"lastModifiedDateTime");
    changeKey = CkJsonObjectW_stringOf(jResp,L"changeKey");
    transactionId = CkJsonObjectW_stringOf(jResp,L"transactionId");
    originalStartTimeZone = CkJsonObjectW_stringOf(jResp,L"originalStartTimeZone");
    originalEndTimeZone = CkJsonObjectW_stringOf(jResp,L"originalEndTimeZone");
    iCalUId = CkJsonObjectW_stringOf(jResp,L"iCalUId");
    reminderMinutesBeforeStart = CkJsonObjectW_IntOf(jResp,L"reminderMinutesBeforeStart");
    isReminderOn = CkJsonObjectW_BoolOf(jResp,L"isReminderOn");
    hasAttachments = CkJsonObjectW_BoolOf(jResp,L"hasAttachments");
    subject = CkJsonObjectW_stringOf(jResp,L"subject");
    bodyPreview = CkJsonObjectW_stringOf(jResp,L"bodyPreview");
    importance = CkJsonObjectW_stringOf(jResp,L"importance");
    sensitivity = CkJsonObjectW_stringOf(jResp,L"sensitivity");
    isAllDay = CkJsonObjectW_BoolOf(jResp,L"isAllDay");
    isCancelled = CkJsonObjectW_BoolOf(jResp,L"isCancelled");
    isOrganizer = CkJsonObjectW_BoolOf(jResp,L"isOrganizer");
    responseRequested = CkJsonObjectW_BoolOf(jResp,L"responseRequested");
    seriesMasterId = CkJsonObjectW_stringOf(jResp,L"seriesMasterId");
    showAs = CkJsonObjectW_stringOf(jResp,L"showAs");
    v_type = CkJsonObjectW_stringOf(jResp,L"type");
    webLink = CkJsonObjectW_stringOf(jResp,L"webLink");
    onlineMeetingUrl = CkJsonObjectW_stringOf(jResp,L"onlineMeetingUrl");
    isOnlineMeeting = CkJsonObjectW_BoolOf(jResp,L"isOnlineMeeting");
    onlineMeetingProvider = CkJsonObjectW_stringOf(jResp,L"onlineMeetingProvider");
    allowNewTimeProposals = CkJsonObjectW_BoolOf(jResp,L"allowNewTimeProposals");
    isDraft = CkJsonObjectW_BoolOf(jResp,L"isDraft");
    hideAttendees = CkJsonObjectW_BoolOf(jResp,L"hideAttendees");
    recurrence = CkJsonObjectW_stringOf(jResp,L"recurrence");
    onlineMeeting = CkJsonObjectW_stringOf(jResp,L"onlineMeeting");
    responseStatusResponse = CkJsonObjectW_stringOf(jResp,L"responseStatus.response");
    responseStatusTime = CkJsonObjectW_stringOf(jResp,L"responseStatus.time");
    bodyContentType = CkJsonObjectW_stringOf(jResp,L"body.contentType");
    bodyContent = CkJsonObjectW_stringOf(jResp,L"body.content");
    startDateTime = CkJsonObjectW_stringOf(jResp,L"start.dateTime");
    startTimeZone = CkJsonObjectW_stringOf(jResp,L"start.timeZone");
    endDateTime = CkJsonObjectW_stringOf(jResp,L"end.dateTime");
    endTimeZone = CkJsonObjectW_stringOf(jResp,L"end.timeZone");
    locationDisplayName = CkJsonObjectW_stringOf(jResp,L"location.displayName");
    locationLocationType = CkJsonObjectW_stringOf(jResp,L"location.locationType");
    locationUniqueId = CkJsonObjectW_stringOf(jResp,L"location.uniqueId");
    locationUniqueIdType = CkJsonObjectW_stringOf(jResp,L"location.uniqueIdType");
    organizerEmailAddressName = CkJsonObjectW_stringOf(jResp,L"organizer.emailAddress.name");
    organizerEmailAddressAddress = CkJsonObjectW_stringOf(jResp,L"organizer.emailAddress.address");
    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"categories");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"locations");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        displayName = CkJsonObjectW_stringOf(jResp,L"locations[i].displayName");
        locationType = CkJsonObjectW_stringOf(jResp,L"locations[i].locationType");
        uniqueId = CkJsonObjectW_stringOf(jResp,L"locations[i].uniqueId");
        uniqueIdType = CkJsonObjectW_stringOf(jResp,L"locations[i].uniqueIdType");
        i = i + 1;
    }

    i = 0;
    count_i = CkJsonObjectW_SizeOfArray(jResp,L"attendees");
    while (i < count_i) {
        CkJsonObjectW_putI(jResp,i);
        v_type = CkJsonObjectW_stringOf(jResp,L"attendees[i].type");
        statusResponse = CkJsonObjectW_stringOf(jResp,L"attendees[i].status.response");
        statusTime = CkJsonObjectW_stringOf(jResp,L"attendees[i].status.time");
        emailAddressName = CkJsonObjectW_stringOf(jResp,L"attendees[i].emailAddress.name");
        emailAddressAddress = CkJsonObjectW_stringOf(jResp,L"attendees[i].emailAddress.address");
        i = i + 1;
    }

    wprintf(L"Event created.\n");


    CkHttpW_Dispose(http);
    CkJsonObjectW_Dispose(jsonToken);
    CkJsonObjectW_Dispose(json);
    CkCrypt2W_Dispose(crypt);
    CkJsonObjectW_Dispose(jResp);

    }

 

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