简体   繁体   English

通过图形创建团队时出现错误请求或冲突 API

[英]BadRequest or Conflict when Create Teams by Graph API

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:我的项目正在使用图形 API V.1 版本 3.8.0 和 .NET 核心 3.1 我创建了一个组“标记”将成员和所有者添加到该组,一切正常,但是当我创建团队时,我收到错误我尝试了两种格式正文内容如下:

1.first Format : 1.第一种格式

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://docs.microsoft.com/en-us/graph/api/team-put-teams?view=graph-rest-1.0&tabs=csharp

result: Status Code: BadRequest结果:状态代码: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 2.second Format 我添加的字段: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??但是当我使用 postman 运行时,结果以 2 格式成功我不明白为什么当我使用 ASP.Net 语句时结果返回错误? Please support me how to fix.请支持我如何解决。 Thanks谢谢

I solved this problem, I did not use SDK Grap API, I used HttpClient to call Create Team API and it worked very good.我解决了这个问题,我没有使用 SDK Grap API,我使用 HttpClient 调用 Create Team API,效果很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM