【发布时间】:2021-08-23 17:48:42
【问题描述】:
我一直在尝试通过 SDK 创建一个 SharePoint 列表项。 SDK 请求在功能上与C# documentation for this type of request. 相同
await client
.Sites[siteId]
.Lists[listId]
.Items
.Request()
.AddAsync(new ListItem
{
Fields = new FieldValueSet
{
AdditionalData = new Dictionary<string, object>
{
{ "Title", "Test" },
{ "Salary", true },
}
}
});
我不断收到以下 500 错误:
"Error": {
"code": "generalException",
"message": "General exception while processing",
"innererror": {
"date": "2021-08-23T17:13:20",
"request-id": "3602eb54-5bde-49ac-abde-16078102746b",
"client-request-id": "3602eb54-5bde-49ac-abde-16078102746b"
}
}
但是,如果我通过 Postman 执行此请求,则请求会成功完成,并且我会看到创建的列表项。
POST https://graph.microsoft.com/v1.0/Sites/[siteid]/lists/[listid]/items
SdkVersion: postman-graph/v2.0
Authorization: Bearer [token]
Content-Type: application/json
User-Agent: PostmanRuntime/7.28.3
Cache-Control: no-cache
Host: graph.microsoft.com
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Content-Length: 32
Request Body
{
"fields" : {
"Title" : "Test",
"Salary" : true
}
}
是不是我做错了什么?
【问题讨论】:
-
通过 Fiddler 捕获传出请求并比较两者。