Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Graph JS
>
Tutorial
> Create contact
The following example shows you how to create a new contact.
import { GraphClient, EmailAddress, Phone, PhoneType } from '../independentsoft/graph/graph.js'; import { Contact } from '../independentsoft/graph/contacts.js'; async function mainFunc() { try { const client = new GraphClient(); client.clientId = "xxxxxxxxxx-209e-454e-xxxxxxxxxxxxxxxxxxx"; client.tenant = "independentsoft.onmicrosoft.com"; client.username = "info@independentsoft.onmicrosoft.com"; client.password = "password"; let contact = new Contact(); contact.displayName = "Alice Smith"; contact.givenName = "Alice"; contact.surname = "Smith"; contact.title = "Dr"; contact.jobTitle = "Software developer"; contact.officeLocation = "Berlin"; contact.emailAddresses.push(new EmailAddress("alice@independentsoft.onmicrosoft.com")); contact.phones.push(new Phone("555-666-777", PhoneType.BUSINESS)); contact.phones.push(new Phone("555-111-777", PhoneType.MOBILE)); const createdContact = await client.createContact(contact); console.log("Id = " + createdContact.id); } catch (e) { console.error(e.code) //error code console.error(e.message) //description console.error(e.date) //timestamp console.error(e.innerError) //innerError } } mainFunc();
Need help? Ask our developers:
Name*
Email*
Message*