pnp / pnpjs

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

graph: Cancel Event #2942

Closed kkazala closed 6 months ago

kkazala commented 6 months ago

What version of PnPjs library you are using

3.x

Minor Version Number

17

Target environment

NodeJS

Additional environment details

I'm writing Azure Function, but it doesn't matter for this question =)

Question/Request

Would it be possible to add cancel to the @pnp/graph/calendars API? Delete doesn't allow defining cancellation message, while cancel does

juliemturner commented 6 months ago

Yes, as we expand the implementation of graph endpoints in v4 this has been already addressed. That said, you can easily do this is v3 by using the graphPost method as explained in the documentation.

kkazala commented 6 months ago

awesome, good to know :) I actually managed to do it with graphPost but I'm not sure if I can/how to batch it

  const id ="AAMkADU...."
  let eventsQuery = GraphQueryable(
            this.graph.users.getById(mailboxId).events,
            `${id}/cancel`
        );
let result = await graphPost(eventsQuery, { body: JSON.stringify({ "Comment": "Cancelling for this week due to all hands" })})

Is batching supported for graphPost?

bcameron1231 commented 6 months ago

Hi! Yes, this can be achieved with graphPost. Please review the following code sample.

const [batch, execute] = graph.batched();

let eventsQuery = GraphQueryable(batch.me.events.getById('123'), '/cancel');
let eventsQuery2 = GraphQueryable(batch.me.events.getById('1234'), '/cancel');

graphPost(eventsQuery, body({ comment: "Cancelling event"}));
graphPost(eventsQuery2, body({ comment: "Cancelling event"}));

await execute();
kkazala commented 6 months ago

thank you @bcameron1231! this was spot on and saved me a lot of time trying to figure it out =)

github-actions[bot] commented 6 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.