microsoftgraph / msgraph-sdk-javascript

Microsoft Graph client library for JavaScript
https://graph.microsoft.com
MIT License
745 stars 225 forks source link

How to get singleValueExtendedProperties? #133

Closed gpierrick closed 5 years ago

gpierrick commented 5 years ago

Hi,

I am using the calendar API in Node.js I created an event with singleValueExtendedProperties

 const eventResource = {
                "subject":"test",
                "isReminderOn": true,
                'body': {
                    "content": 'Booking'
                },
                'start': {
                    'dateTime': data.start,
                    'timeZone': data.timezone
                },
                'end': {
                    'dateTime': data.end,
                    'timeZone': data..timezone
                },
                'singleValueExtendedProperties': [
                    {
                        "id": "String {66f5a359-4659-4830-9070-00040ec6ac6e} Name id",
                        "value": data.booking.id.toString()
                    },
                    {
                        "id": "String {66f5a359-4659-4830-9070-00040ec6ac6e} Name uid",
                        "value": data.booking.uid.toString()
                    },
                    {
                        "id": "String {66f5a359-4659-4830-9070-00040ec6ac6e} Name type",
                        "value": data.event.kind
                    }
                ]
            };
 const result = await client
                .api(`/me/calendars/${calendarSync.providerId}/events`)
                .version('beta')
                .post(eventResource);

Then using this

 const result = await client
                .api(`/me/calendars/${calendarId}/calendarView?startDateTime=${start}&endDateTime=${end}`)
                .version('beta')
                .expand('singleValueExtendedProperties')
                .orderby('start/dateTime DESC')
                .get();

I have tried with and without beta and I have with this in the URL $expand=singleValueExtendedProperties

Been followhing this article https://github.com/microsoftgraph/microsoft-graph-docs/blob/master/api-reference/v1.0/api/calendar-list-events.md#list-events

Not sure what I am doing wrong?

gpierrick commented 5 years ago

had to change my odata query to

const result = await client
                .api(`/me/calendars/${calendarSync.providerId}/calendarView?startDateTime=${start}&endDateTime=${end}`)
                .version('beta')
                .expand("singleValueExtendedProperties($filter=(id eq 'String {66f5a359-4659-4830-9070-00040ec6ac6e} Name id' or id eq 'String {66f5a359-4659-4830-9070-00040ec6ac6e} Name uid' or id eq 'String {66f5a359-4659-4830-9070-00040ec6ac6e} Name type'))")
                .orderby('start/dateTime DESC')
                .get();