3

my project is using graph API V.1 version 3.8.0 and .NET core 3.1 I created a group "mark" add member and owner to this group , Everything worked very well but when I create Team Then I receive Error I tried two format body with content below :

1.first Format :

var groups = await graphClient.Groups.Request().GetAsync()
 
var team = new Team 
{
    
MemberSettings = new TeamMemberSettings
    {
        
       AllowCreateUpdateChannels = true
    },
    MessagingSettings = new TeamMessagingSettings
    {
        AllowUserEditMessages = true,
        AllowUserDeleteMessages = true
    },
    FunSettings = new TeamFunSettings
    {
        AllowGiphy = true,
        GiphyContentRating = GiphyRatingType.Strict
    }
};

await graphClient.Groups[groups.Id].Team.Request().PutAsync(team);

I have reference from [1]: https://learn.microsoft.com/en-us/graph/api/team-put-teams?view=graph-rest-1.0&tabs=csharp

result : Status Code: BadRequest

Microsoft.Graph.ServiceException: Code: BadRequest
Message: Bad Request

Inner error:
        AdditionalData:
        date: 2020-07-15T22:49:41
        
request-id: 865a9ce7-21ea-4a3e-bbc4-88fb7f88b7ca

ClientRequestId: 865a9ce7-21ea-4a3e-bbc4-88fb7f88b7ca

2.second Format I added field : ODataType = null

var groups = await graphClient.Groups
                          .Request()
                          .GetAsync();

Team team = new Team

            {
                MemberSettings = new TeamMemberSettings
                {
                    AllowCreateUpdateChannels = true,
                    ODataType = null
                },
                MessagingSettings = new TeamMessagingSettings
                {
                    AllowUserEditMessages = true,
                    AllowUserDeleteMessages = true,
                    ODataType = null
                },
                FunSettings = new TeamFunSettings
                {
                    AllowGiphy = true,
                    GiphyContentRating = GiphyRatingType.Strict,
                    ODataType = null
                },
                ODataType = null
            };

            await graphClient.Groups[groups.Id].Team
                .Request()
                .PutAsync(team);

result : Status Code: Conflict

Microsoft.Graph.ServiceException: Code: Conflict

Message: Conflict

Inner error:
        AdditionalData:
        date: 2020-07-15T22:49:36
        request-id: a218abee-c090-4a70-a072-ab33db5486dd

ClientRequestId: a218abee-c090-4a70-a072-ab33db5486dd 

but when I run with postman then result success with 2 format I don't understand why the result return error when i use the ASP .Net statement ?? Please support me how to fix . Thanks

Minh Do
  • 35
  • 1
  • 7

1 Answers1

0

I solved this problem , I did not use SDK Grap API , I used HttpClient to call Create Team API and it worked very good .

Minh Do
  • 35
  • 1
  • 7