I am trying to create an MS Planner Plan, using a Post call to MS Graph, as described under https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/planner_post_plans

The sequence I follow is:

  1. As a first step I create a new Office 365 group. This process completes successfully, using a post call to: .api("https://graph.microsoft.com/v1.0/groups/")

  2. Then I add the currently logged user, who is executing the operation, as a group member (since by default he becomes a group owner only, and a member permission is required to perform further operations with the group), using a post call to:

"https://graph.microsoft.com/v1.0/groups/" + o365GroupId + "/members/$ref"

  1. If at this point I decide to perform .get calls to the URLs, quoted above and console.log the responses, is obvious that the group has been created successfully, and the currently logged user has been added as a member.

  2. If then I try to create a plan for this group, using a .Post call to: "https://graph.microsoft.com/v1.0/planner/plans", I get a 403 (Forbidden) response and a "You do not have the required permissions to access this item, or the item may not exist." error message.

That means, from Planner point of view either the group still doesn't exist, or my permission to it hasn't been recognized.

But if I put a breakpoint in the browser development tools, and just await a little bit, while the code is in paused state, so it has some time to recognize that the group and the permission exist, then the code from step 4. gets executed successfully and the Plan is being actually created. Afterwards I decided to experiment with the setTimeout() JavaScript function in order to somehow get the code paused automatically for a certain period (let's say 5-10 seconds), but looks like an unstable solution - sometimes it works and sometimes it doesn't.

However I don't quite get it why there is an issue with this at all, since the whole function is from 'async' type, and all my Graph calls begin with 'await' in order to ensure synchronous code execution.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.