gpt4 book ai didi

c# - Microsoft.Graph.GraphServiceClient Planner Buckets AddAsync 返回错误 "Write requests are only supported on contained entities"

转载 作者:太空宇宙 更新时间:2023-11-03 12:07:12 28 4
gpt4 key购买 nike

我有一些代码可以获取或创建 Planner Bucket .

public async Task<PlannerBucket> GetOrCreateBucket(GraphServiceClient graphServiceClient, string planId, string name)
{
var buckets = await graphServiceClient
.Planner
.Plans[planId]
.Buckets
.Request()
.GetAsync();

var bucket = buckets.SingleOrDefault(b => b.Name.Equals(name));

if (bucket == null)
{
bucket = await graphServiceClient
.Planner
.Plans[planId]
.Buckets
.Request()
.AddAsync(new PlannerBucket()
{
Name = name
});
}

return bucket;
}

一年前最初编写这段代码时,我相当确定它工作正常。

早期经常有新的 buckets 并且创建的很好。从那以后创建代码很少被调用,最近调用它时返回错误:

Microsoft.Graph.ServiceException: Code: BadRequest
Message: Write requests are only supported on contained entities

我不太确定这个错误是什么意思。

实体被收容是什么意思?
为什么不包含它?
它甚至意味着哪个实体?
这是否意味着我正在尝试创建的存储桶?
这是否意味着我试图在其中创建它的计划?

这些问题的答案会很好,因为它们可以帮助我理解如何解决问题,但归根结底,真正的问题是:“我做错了什么,我该如何纠正?”。

这是 HTTP 请求:

POST https://graph.microsoft.com/v1.0/planner/plans/__PLANID__/buckets HTTP/1.1
Cache-Control: no-store, no-cache
Connection: Keep-Alive
Content-Type: application/json
Authorization: Bearer __TOKEN__
SdkVersion: Graph-dotnet-1.7.0
x-ms-request-root-id: 309b7fa3-4c57a2db0536dddc
x-ms-request-id: |309b7fa3-4c57a2db0536dddc.2.
Request-Id: |309b7fa3-4c57a2db0536dddc.2.1.
Content-Length: 30
Host: graph.microsoft.com

{"name":"__BUCKETNAME__"}

这是响应:

HTTP/1.1 400 Bad Request
Cache-Control: private
Transfer-Encoding: chunked
Content-Type: application/json
request-id: 5186e2aa-7a1c-4f86-88c4-5542ef89e6c9
client-request-id: 5186e2aa-7a1c-4f86-88c4-5542ef89e6c9
x-ms-ags-diagnostic: __DIAGNOSTICINFO__
Duration: 2.7551
Strict-Transport-Security: max-age=31536000
Date: Thu, 24 Jan 2019 13:08:52 GMT

fb
{
"error": {
"code": "BadRequest",
"message": "Write requests are only supported on contained entities",
"innerError": {
"request-id": "5186e2aa-7a1c-4f86-88c4-5542ef89e6c9",
"date": "2019-01-24T13:08:53"
}
}
}
0

搜索了一下,我认为这个问题已经在 github 上报告过,但目前仍未解决:https://github.com/microsoftgraph/msgraph-sdk-dotnet/issues/307

最佳答案

此处的错误消息不是很有用,但问题是我们不允许 POST 到 planner/plans/planid/buckets。您应该将请求发送到 planner/buckets 并在请求正文中包含 planid 属性。文档中的示例是准确的(顺序提示是可选的):https://learn.microsoft.com/en-us/graph/api/planner-post-buckets?view=graph-rest-1.0

关于c# - Microsoft.Graph.GraphServiceClient Planner Buckets AddAsync 返回错误 "Write requests are only supported on contained entities",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54347506/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com