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

Node.js 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

 

 

 

(Node.js) Outlook List Contacts

See more Outlook Contact Examples

List Outlook Contacts

For more information, see https://docs.microsoft.com/en-us/graph/api/user-list-contacts?view=graph-rest-1.0&tabs=http

Install Chilkat for Node.js and Electron using npm at

Chilkat npm packages for Node.js

Chilkat npm packages for Electron

on Windows, Linux, MacOSX, and ARM

var os = require('os');
if (os.platform() == 'win32') {  
    if (os.arch() == 'ia32') {
        var chilkat = require('@chilkat/ck-node21-win-ia32');
    } else {
        var chilkat = require('@chilkat/ck-node21-win64'); 
    }
} else if (os.platform() == 'linux') {
    if (os.arch() == 'arm') {
        var chilkat = require('@chilkat/ck-node21-arm');
    } else if (os.arch() == 'x86') {
        var chilkat = require('@chilkat/ck-node21-linux32');
    } else {
        var chilkat = require('@chilkat/ck-node21-linux64');
    }
} else if (os.platform() == 'darwin') {
    if (os.arch() == 'arm64') {
        var chilkat = require('@chilkat/ck-node21-mac-m1');
    } else {
        var chilkat = require('@chilkat/ck-node21-macosx');
    }
}

function chilkatExample() {

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

    var http = new chilkat.Http();

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

    var jsonToken = new chilkat.JsonObject();
    var success = jsonToken.LoadFile("qa_data/tokens/outlookContacts.json");
    if (success == false) {
        console.log(jsonToken.LastErrorText);
        return;
    }

    http.AuthToken = jsonToken.StringOf("access_token");

    // Send the following GET:

    // GET https://graph.microsoft.com/v1.0/me/contacts
    var sbJson = new chilkat.StringBuilder();
    success = http.QuickGetSb("https://graph.microsoft.com/v1.0/me/contacts",sbJson);
    if (success == false) {
        console.log(http.LastErrorText);
        return;
    }

    var statusCode = http.LastStatus;
    console.log("Response status code = " + statusCode);

    if (statusCode !== 200) {
        console.log(sbJson.GetAsString());
        console.log("Failed.");
        return;
    }

    var jResp = new chilkat.JsonObject();
    jResp.LoadSb(sbJson);
    jResp.EmitCompact = false;
    console.log(jResp.Emit());

    // Sample output:

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

    // {
    //   "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('4ee732c3-322e-4a6b-b729-2fd1eb5c6004')/contacts",
    //   "value": [
    //     {
    //       "@odata.etag": "W/\"EQAAABYAAABUcG0qWqkmQYqWLHQataQxAAD0iYfT\"",
    //       "id": "AAMkADYzZWE3YmZmLWU0YzgtNGNkZC04MGE1LWFiYTFlNTRlY2QwYQBGAAAAAAAu7cUXL5YOTrdsUIw7-v8FBwBUcG0qWqkmQYqWLHQataQxAAAAAAEOAABUcG0qWqkmQYqWLHQataQxAAD0sxexAAA=",
    //       "createdDateTime": "2021-06-29T16:32:05Z",
    //       "lastModifiedDateTime": "2021-06-29T16:32:06Z",
    //       "changeKey": "EQAAABYAAABUcG0qWqkmQYqWLHQataQxAAD0iYfT",
    //       "categories": [
    //       ],
    //       "parentFolderId": "AAMkADYzZWE3YmZmLWU0YzgtNGNkZC04MGE1LWFiYTFlNTRlY2QwYQAuAAAAAAAu7cUXL5YOTrdsUIw7-v8FAQBUcG0qWqkmQYqWLHQataQxAAAAAAEOAAA=",
    //       "birthday": null,
    //       "fileAs": "",
    //       "displayName": "Pavel Bansky",
    //       "givenName": "Pavel",
    //       "initials": null,
    //       "middleName": null,
    //       "nickName": null,
    //       "surname": "Bansky",
    //       "title": null,
    //       "yomiGivenName": null,
    //       "yomiSurname": null,
    //       "yomiCompanyName": null,
    //       "generation": null,
    //       "imAddresses": [
    //       ],
    //       "jobTitle": null,
    //       "companyName": null,
    //       "department": null,
    //       "officeLocation": null,
    //       "profession": null,
    //       "businessHomePage": null,
    //       "assistantName": null,
    //       "manager": null,
    //       "homePhones": [
    //       ],
    //       "mobilePhone": null,
    //       "businessPhones": [
    //         "+1 732 555 0102"
    //       ],
    //       "spouseName": null,
    //       "personalNotes": "",
    //       "children": [
    //       ],
    //       "emailAddresses": [
    //         {
    //           "name": "Pavel Bansky",
    //           "address": "pavelb@fabrikam.onmicrosoft.com"
    //         }
    //       ],
    //       "homeAddress": {},
    //       "businessAddress": {},
    //       "otherAddress": {}
    //     },
    // ...
    //   ]
    // }

    var odata_etag;
    var id;
    var createdDateTime;
    var lastModifiedDateTime;
    var changeKey;
    var parentFolderId;
    var birthday;
    var fileAs;
    var displayName;
    var givenName;
    var initials;
    var middleName;
    var nickName;
    var surname;
    var title;
    var yomiGivenName;
    var yomiSurname;
    var yomiCompanyName;
    var generation;
    var jobTitle;
    var companyName;
    var department;
    var officeLocation;
    var profession;
    var businessHomePage;
    var assistantName;
    var manager;
    var mobilePhone;
    var spouseName;
    var personalNotes;
    var j;
    var count_j;
    var strVal;
    var name;
    var address;

    var odata_context = jResp.StringOf("\"@odata.context\"");
    var i = 0;
    var count_i = jResp.SizeOfArray("value");
    while (i < count_i) {
        jResp.I = i;
        odata_etag = jResp.StringOf("value[i].\"@odata.etag\"");
        id = jResp.StringOf("value[i].id");
        createdDateTime = jResp.StringOf("value[i].createdDateTime");
        lastModifiedDateTime = jResp.StringOf("value[i].lastModifiedDateTime");
        changeKey = jResp.StringOf("value[i].changeKey");
        parentFolderId = jResp.StringOf("value[i].parentFolderId");
        birthday = jResp.StringOf("value[i].birthday");
        fileAs = jResp.StringOf("value[i].fileAs");
        displayName = jResp.StringOf("value[i].displayName");
        givenName = jResp.StringOf("value[i].givenName");
        initials = jResp.StringOf("value[i].initials");
        middleName = jResp.StringOf("value[i].middleName");
        nickName = jResp.StringOf("value[i].nickName");
        surname = jResp.StringOf("value[i].surname");
        title = jResp.StringOf("value[i].title");
        yomiGivenName = jResp.StringOf("value[i].yomiGivenName");
        yomiSurname = jResp.StringOf("value[i].yomiSurname");
        yomiCompanyName = jResp.StringOf("value[i].yomiCompanyName");
        generation = jResp.StringOf("value[i].generation");
        jobTitle = jResp.StringOf("value[i].jobTitle");
        companyName = jResp.StringOf("value[i].companyName");
        department = jResp.StringOf("value[i].department");
        officeLocation = jResp.StringOf("value[i].officeLocation");
        profession = jResp.StringOf("value[i].profession");
        businessHomePage = jResp.StringOf("value[i].businessHomePage");
        assistantName = jResp.StringOf("value[i].assistantName");
        manager = jResp.StringOf("value[i].manager");
        mobilePhone = jResp.StringOf("value[i].mobilePhone");
        spouseName = jResp.StringOf("value[i].spouseName");
        personalNotes = jResp.StringOf("value[i].personalNotes");
        j = 0;
        count_j = jResp.SizeOfArray("value[i].categories");
        while (j < count_j) {
            jResp.J = j;
            j = j+1;
        }

        j = 0;
        count_j = jResp.SizeOfArray("value[i].imAddresses");
        while (j < count_j) {
            jResp.J = j;
            j = j+1;
        }

        j = 0;
        count_j = jResp.SizeOfArray("value[i].homePhones");
        while (j < count_j) {
            jResp.J = j;
            j = j+1;
        }

        j = 0;
        count_j = jResp.SizeOfArray("value[i].businessPhones");
        while (j < count_j) {
            jResp.J = j;
            strVal = jResp.StringOf("value[i].businessPhones[j]");
            j = j+1;
        }

        j = 0;
        count_j = jResp.SizeOfArray("value[i].children");
        while (j < count_j) {
            jResp.J = j;
            j = j+1;
        }

        j = 0;
        count_j = jResp.SizeOfArray("value[i].emailAddresses");
        while (j < count_j) {
            jResp.J = j;
            name = jResp.StringOf("value[i].emailAddresses[j].name");
            address = jResp.StringOf("value[i].emailAddresses[j].address");
            j = j+1;
        }

        i = i+1;
    }


}

chilkatExample();

 

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