Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
Graph JS
>
Tutorial
> Create appointment (event)
The following example shows you how to create an appointment (event).
import { GraphClient, Location, LocationType, ItemBody, ContentType } from '../independentsoft/graph/graph.js'; import { Event, DateTimeTimeZone } from '../independentsoft/graph/calendars.js'; import { UserId } from '../independentsoft/graph/users.js'; async function mainFunc() { try { const client = new GraphClient(); client.clientId = "xxxxxxxxxx-209e-454e-xxxxxxxxxxxxxxxxxxx"; client.tenant = "independentsoft.onmicrosoft.com"; client.clientSecret = "xxxxxxxxx.ONVE[=zYYxxxxxxxxxxxxxxxx"; const start = new Date(2023, 6, 10, 16, 0, 0); const end = new Date(2023, 6, 10, 17, 0, 0); let appointment = new Event(); appointment.subject = "Development meeting"; appointment.body = new ItemBody("Body text can be html or plain text. We set it now as a plain text.", ContentType.TEXT); appointment.start = new DateTimeTimeZone(start, "Pacific Standard Time"); appointment.end = new DateTimeTimeZone(end, "Pacific Standard Time"); let location = new Location(); location.displayName = "Office 123"; location.type = LocationType.CONFERENCE_ROOM; appointment.location = location; const createdAppointment = await client.createEvent(appointment, undefined, new UserId("info@independentsoft.onmicrosoft.com")); console.log("Id = " + createdAppointment.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*