2

I am trying to create a new group and team via the Graph API. I am trying to run the POST a request in Graph Explorer (https://developer.microsoft.com/en-us/graph/graph-explorer) as below but get a bad request.

Request: POST
Version: v1.0
URL: https://graph.microsoft.com/v1.0/teams/groups
Request Body: 
{
    "displayName":"Flight 157",
    "mailNickname":"flight157",
    "description":"Everything about flight 157",
    "visibility":"Private",
    "groupTypes":["Unified"],
    "mailEnabled":true,
    "securityEnabled":false,
    "members@odata.bind":[
        "https://graph.microsoft.com/v1.0/users/957c07af-dcad-4b72-9306-1c4ee7d04e1f"
    ],
    "owners@odata.bind":[
        "https://graph.microsoft.com/v1.0/users/957c07af-dcad-4b72-9306-1c4ee7d04e1f"
    ]
}

I get the below response error:

{
    "error": {
        "code": "BadRequest",
        "message": "Invalid bind property name members in request.",
        "innerError": {
            "request-id": "fee10382-5112-44f8-a8c9-683453bdf050",
            "date": "2020-03-05T01:08:19"
        }
    }
}

I am not quite sure what I am doing wrong. Can anyone please help me with this?

lsam
  • 21
  • 2
  • Your post looks ok to me in terms of structure, but the error message is saying it's not happy with the "members" you're posting. Are you adding in a user, or a group, as the member, out of interest? – Hilton Giesenow Mar 05 '20 at 03:47
  • Creating a group that includes a team involves two steps: Create a group with the right properties & Add a team to the group.Please take a look at [creating group with microsoft teams team](https://learn.microsoft.com/en-us/graph/teams-create-group-and-team), [create a group](https://learn.microsoft.com/en-us/graph/api/group-post-groups?view=graph-rest-1.0&tabs=http#example-1-create-an-office-365-group) – Trinetra-MSFT Mar 05 '20 at 06:18
  • @Trinetra-MSFT, I also thought you needed to do it that way, but when I was looking into this question earlier today, I saw this sample: https://learn.microsoft.com/en-us/graph/api/group-post-groups?view=graph-rest-1.0&tabs=http#example-2-create-a-group-with-owners-and-members . Is that example incorrect? – Hilton Giesenow Mar 05 '20 at 08:13
  • @HiltonGiesenow, The issue is seems to be in the Post endpoint which he is trying to call, The example in the document is correct one. He is trying to create the Group and Team in one POST call that's why it's throwing error. – Trinetra-MSFT Mar 05 '20 at 13:31
  • Ahh, good point! So this call should be to "https://graph.microsoft.com/v1.0/groups", and THEN to convert it to a "Team". OR (1) create Team and then (2) add members - either option I guess would work, but not combined like this? – Hilton Giesenow Mar 05 '20 at 13:46
  • Thank you for your responses. @Trinetra-MSFT you are right. I tried creating the group first and then the team and it worked for me. I was following the steps in PnPJS (https://pnp.github.io/pnpjs/v1/graph/docs/teams/#create-new-group-and-team) to do both the steps in one but that didn't work for me – lsam Mar 06 '20 at 04:49

0 Answers0