Microsoft Graph - 使用空的SharePoint ChoiceField问题

时间:2018-04-03 11:19:55

标签: sharepoint microsoft-graph

调用

时,我收到了意想不到的响应

https://graph.microsoft.com/v1.0/sites/root/lists/SomeList?$expand=items($expand=fields)

如果我有一个类型为“选择字段”的字段“部门”,其中某些项目没有选择,我会得到以下(缩写)响应:

{
    items: [
        {
            fields: {
                Id: "some-item-without-selection"
                // No Departments field
            }
        },
        {
            fields: {
                Id: "some-item-with-selection",
                Departments: ["Sales"]
            }
        }
    ]
}

我希望回复中的第一项是这样的:

{
    items: [
        {
            fields: {
                Id: "some-item-without-selection",
                Departments: [] // Empty array
            }
        }
    ]
}

我们遇到一个字段(列)是可选的情况。定义该字段后,它将为某个项启用其他功能。

在这种情况下,空数组(在ChoiceField中未选择任何内容)与在列表中未定义该字段的情况不同。因此,我们无法将这两种情况与Microsoft Graph API中的当前实现区分开来。

附注1:我们可以使用SharePoint REST API执行此操作。

附注2:api Title: ""

返回空文本字段

这是预期的行为吗?

1 个答案:

答案 0 :(得分:0)

根据图谱API的设计,作为变通方法,您可以为此字段设置默认值。

要访问SharePoint列表数据,我建议您使用SharePoint REST API来实现它。

/_api/web/lists/getbytitle('SomeList')/items
相关问题