1

I have a problem with creating teams using the Microsoft Graph Api. I can get/create groups but when I try to get/create teams I get an error. I'm using postman and the group has owners and members, just as the documentation of MS, also has the permissitions it asks for groups. If somebody can help me, cause I look everywhere for a same error but no found it.

PUT https://graph.microsoft.com/v1.0/groups/{id}/team

Headers: Authorization: bearer token and content-type: json

Body is

{  
  "memberSettings": {
    "allowCreateUpdateChannels": true
  },
  "messagingSettings": {
    "allowUserEditMessages": true,
    "allowUserDeleteMessages": true
  },
  "funSettings": {
    "allowGiphy": true,
    "giphyContentRating": "strict"
  }
}

I always get the same error

{
  "error": {
    "code": "BadGateway",
    "message": "Failed to execute backend request.",
    "innerError": {
      "request-id": "45eeba8a-9d35-45e8-b42e-c60da7a47dde",
      "date": "2020-01-23T21:55:44"
    }
  }
}
2
  • Was it a bug in the Microsoft Graph API? Commented Apr 20, 2020 at 14:09
  • If it was, it's still there even on the beta endpoint. For me, my Teams are created, but that error is dis-concerting. Commented Jul 7, 2020 at 14:55

1 Answer 1

1

According to the Graph API docs for this, you're not calling the correct endpoint to create a new Team. It should be

POST https://graph.microsoft.com/beta/teams

and a payload similar to

Content-Type: application/json
{
  "[email protected]": "https://graph.microsoft.com/beta/teamsTemplates('standard')",
  "displayName": "My Sample Team",
  "description": "My Sample Team’s Description",
  "[email protected]": [
    "https://graph.microsoft.com/beta/users('userId')"
  ]
}

Note that it's slightly different, as per the docs, whether you're using delegated versus application permissons.

Sign up to request clarification or add additional context in comments.

8 Comments

When creating a Team using the Teams endpoint, the API returns no data; not even an Id for the newly created object. You also can't create a team with [email protected] like you can with a group. In order to add members to the team you then have to search groups endpoint with a filter clause (note: displayName works but this might not be unique) to obtain the Id, and then make another request to add members (untested). I've been attempting to create a group with owners and members in 1 request which returns the Id, then upgrade to a team. I get OPs error, but the team is created.
It's been a while since I last did this, but I seem to recall the docs being correct. They list the response as containing "Content-Location: /teams/{teamId}". Are you not seeing that? Note that it's a HEADER, not part of the BODY payload.
Ah, I'd assumed that because Invoke-RestMethod returned with zero display, and the docs say Content-Length: 0, that nothing was being returned. I'd not considered they'd put the Id in the header. That's... problematic :) Maybe Invoke-WebRequest has to be used.
Confirmed. Sending the create request as $data = Invoke-WebRequest ... means you can inspect the return response like so: $data.headers["Location"] and the value is something like /teams('a1111111-11d1-41ae-11ff-d1bc011cfc1b')/operations('b1d111b1-1f1d-1cc1-1cf1-11c1f110f1f1)
ok great, so that sounds like you got what you needed?
|

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.