我的项目使用的是图API V.1版本3.8.0和.NET Core 3.1,我创建了一个“标记”组,向该组添加成员和所有者,一切工作得很好,但是当我创建团队时,我收到了错误消息 我尝试了以下内容的两种格式的正文:
1.first格式:
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
结果:状态代码: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我添加的格式字段: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
但是当我和邮递员一起跑步时,结果成功有两种格式 我不明白为什么我使用ASP .Net语句时结果返回错误?请支持我如何解决。谢谢
答案 0 :(得分:0)
我解决了这个问题,我没有使用SDK Grap API,而是使用HttpClient调用Create Team API,并且效果很好。