我的项目正在使用图形 API V.1 版本 3.8.0 和 .NET 核心 3.1 我创建了一个组“标记”向该组添加成员和所有者,一切都很好但是当我创建团队时然后我收到错误 我尝试了两种格式正文,内容如下:
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://learn.microsoft.com/en-us/graph/api/team-put-teams?view=graph-rest-1.0&tabs=csharp
结果:状态代码: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);
结果:状态代码:冲突
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
但是当我与 postman 一起运行时,结果成功,格式为 2 我不明白为什么当我使用 ASP .Net 语句时结果返回错误??请支持我如何修复。谢谢
最佳答案
我解决了这个问题,我没有使用 SDK Graph API,我使用 HttpClient 调用 Create Team API 并且效果很好。
关于c# - 通过 Graph API 创建团队时出现 BadRequest 或冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62925228/