我正在尝试使用Microsoft Graph创建SharePoint ListItem。
我用于POST / PATCH var
的方法正常工作,除非我将这些方法应用于包含对象的列表(如组,用户甚至图像)。
在我的示例中,我将发布,修补或从ListItems
获取。
SharePoint ListItem
/beta/sites/root/lists/1231231231234/items/4/fields
工作示例(注意:这是有效的,因为我更新了像'Title'这样的类型为String的简单字段)
{
"@odata.context":
"https://graph.microsoft.com/beta/$metadata#sites('root')/lists('1234123412341234')/items('4')/fields/$entity",
"@odata.etag": "\"123412341234,18\"",
"Title": "Test Title",
"description": "Some random description",
"assignedGroups": [
{
"LookupId": 7818,
"LookupValue": "7818",
"Email": "DemoGroep@12341234.onmicrosoft.com"
},
{
"LookupId": 7822,
"LookupValue": "7822",
"Email": "TestDemo@12341234.onmicrosoft.com"
}
],
"startDate": "2018-05-15T07:00:00Z",
"endDate": "2018-08-18T07:00:00Z",
"alwaysAvailable": false,
"id": "4",
"ContentType": "Item",
"Modified": "2018-05-17T13:27:21Z",
"Created": "2018-04-03T09:34:49Z",
"AuthorLookupId": "7688",
"EditorLookupId": "5222",
"_UIVersionString": "1.0",
"Attachments": false,
"Edit": "",
"LinkTitleNoMenu": "Test123123",
"LinkTitle": "Test123123",
"ItemChildCount": "0",
"FolderChildCount": "0",
"_ComplianceFlags": "",
"_ComplianceTag": "",
"_ComplianceTagWrittenTime": "",
"_ComplianceTagUserId": "",
"AppEditorLookupId": "25"
}
不工作示例(返回{
Title: "SomeNewTitle"
}
)
400 'The request is malformed or incorrect.'
我在这里尝试了多种对象,但它永远不会工作..即使是空数组(清除组成员资格)也会返回{
assignedGroups: [{"Email": "Test1003@12341234o.onmicrosoft.com"}]
}
状态。
我觉得这是图谱API中的限制/错误
答案 0 :(得分:1)
遗憾的是,这是Microsoft Graph的SharePoint API的一个已知问题。有一个UserVoice request to fix this,绝对可以使用更多的选票。
答案 1 :(得分:0)
尝试像这样的PATCH主体:
listItem
因为在assignedGroups
中它返回了//PATCH
{
assignedGroups: [{"Email": "Test1003@StichtingNuovo.onmicrosoft.com"},
{"Email": "AnotherEmail@microsoft.com"}
]
}
的数组,但您只更新了一个。如果您需要更新多个,我相信电话会是:
foreach($results['result'] as $result)
{
$thumbnail = apply_filters('jnews_image_lazy_owl', $result->ID, 'jnews-360x180');
$additional_class = (!has_post_thumbnail( $result->ID )) ? 'no_thumbnail' : '';
$article_output .=
"<div class=\"jeg_newsfeed_item {$additional_class}\">
<div class=\"jeg_thumb\">
" . jnews_edit_post( $result->ID ) . "
<a href=\"" . get_the_permalink($result) . "\">" . $thumbnail . "</a>
</div>
<h3 class=\"jeg_post_title\"><a href=\"" . get_the_permalink($result) . "\">" . get_the_title($result) . "</a></h3>
</div>";
}
return $article_output;