pnp / pnpjs

Fluent JavaScript API for SharePoint and Microsoft Graph REST APIs
https://pnp.github.io/pnpjs/
Other
753 stars 305 forks source link

CalendarView getDelta #2952

Closed kkazala closed 5 months ago

kkazala commented 5 months ago

What version of PnPjs library you are using

3.x

Minor Version Number

17

Target environment

All

Additional environment details

The question is not environment specific

Question/Request

I want to retrieve changes to the calendar events as described in Get delta The CalendarView doesn't return @odata.deltaLink I tried using graphGet:

const events = this.graph.users.getById(sharedMailbox); 
const eventsQuery = GraphQueryable(events, `/calendarView/delta?startDateTime=2024-03-04&endDateTime=2024-03-22&`);
const result= await graphGet(eventsQuery);

but the @odata.deltaLink is also removed. Is there a way to retrieve it, using pnp js?

bcameron1231 commented 5 months ago

Hi, the delta query may not always contain a deltaLink, it may contain a nextLink instead. You'll get one or the other depending on if you've completed the getting all the changes, or if there are still more changes you need to retrieve.

Can you confirm if you have a @data.nextLink in the response?

kkazala commented 5 months ago

@bcameron1231 I don't. Neither @odata.deltaLink nor @data.nextLink I have only 1 item that changed during this time span, so I should get @odata.deltaLink, but it looks like it's removed for some reason

bcameron1231 commented 5 months ago

Hi @kkazala . Ah, my apologies. The reason is that the PnPjs default parser is used when using graphGet. This parser only returns the value from the response. In order to fix this, you can use the JSONParse behavior on your spfi or Graph Queryable objects.

Here is an example of doing it right on the eventsQuery GraphQueryable object.

const events = this.graph.users.getById(sharedMailbox); 
const eventsQuery = GraphQueryable(events, `/calendarView/delta?startDateTime=2024-03-04&endDateTime=2024-03-22&`).using(JSONParse());
const result= await graphGet(eventsQuery);

This could also be done for all graph requests if you wish. const graph = graphfi().using(JSONParse());

patrick-rodgers commented 5 months ago

We will also have better delta support in v4.

patrick-rodgers commented 5 months ago

Closing this issue as answered. If you have additional questions or we did not answer your question, please open a new issue, ref this issue, and provide any additional details available. Thank you!

github-actions[bot] commented 5 months ago

This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.