0

I just follow this official document to excuse create a team.Create team I also using the client credential flow and apply all the permissions advised. In Postman, I used this message to call

{
   "[email protected]":"https://graph.microsoft.com/v1.0/teamsTemplates('standard')",
   "displayName":"My Sample Team",
   "description":"My Sample Team’s Description",
   "members":[
      {
         "@odata.type":"#microsoft.graph.aadUserConversationMember",
         "roles":[
            "owner"
         ],
         "userId":"xxxxx-61d8-43db-94f5-81374122dc7e"
      }
   ]
}

but unfortunately will get such error message, I'm fully confused on this unknown Error

{
  "error": {
    "code": "UnknownError",
    "message": "",
    "innerError": {
      "date": "2020-11-02T05:32:08",
      "request-id": "2955c466-f25f-42f5-ba89-4a522c428b70",
      "client-request-id": "2955c466-f25f-42f5-ba89-4a522c428b70"
    }
  }
}

I also tried to execute it in C# code

var team = new Team
        {
            DisplayName = "My Sample Team558",
            Description = "My Sample Team’s Description558",
            Members = new TeamMembersCollectionPage() {
                new AadUserConversationMember
                {
                    Roles = new List<String>()
                    {
                        "owner"
                    },
                    UserId = "9xxxxxc9-f062-48e2-8ced-22xxxxx6dfce"
                }
            },
            AdditionalData = new Dictionary<string, object>()
            {
                {"[email protected]", "https://graph.microsoft.com/v1.0/teamsTemplates('standard')"}
            }
        };
 var result = await graphServiceClient.Teams
            .Request()
            .AddAsync(team);

This async call will be executed successfully and a new teams team will be also created, but the result return null, that means I could not get the team id from the result. I could not go to the next step, such as add a new channel etc. I'm using Microsoft.Graph v3.18.0.0 in my C# code。

UPDATE Here is the accesstoken enter image description here

1
  • In summary, in current graph API if you call the API without a proper permission. Such as did not grant the permissions ,grant admin consent, access token without a role, you will get the unknown ERROR. Commented Nov 3, 2020 at 7:16

1 Answer 1

1

I can easily reproduce your problem. The cause of this error may be that you did not grant the necessary permissions or did not grant the admin consent for this permission.

enter image description here

Therefore, you need to check that you have granted the necessary application permissions and Permission is granted to the admin consent.

enter image description here

enter image description here

code:

GraphServiceClient graphClient = new GraphServiceClient( authProvider );

var team = new Team
{
    DisplayName = "My Sample Team",
    Description = "My Sample Team’s Description",
    AdditionalData = new Dictionary<string, object>()
    {
        {"[email protected]", "https://graph.microsoft.com/v1.0/teamsTemplates('standard')"}
    }
};

await graphClient.Teams
    .Request()
    .AddAsync(team);
Sign up to request clarification or add additional context in comments.

14 Comments

Yes,if we didn't set the permission will also get this unknown error. But actually I already granted all these permissions under my application.
@KevinYANG Use jwt.ms to parse your access token and provide screenshots.
regarding to my second question,the result return null.I found this link (AddAsync(team) returns null)<github.com/microsoftgraph/msgraph-beta-sdk-dotnet/issues/… how should I get the team id after we request a new team via API
,Please see the screenshot in the question UPDATE
I'm using client credential flow to get the access token when tested in postman
|

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.