SharePoint 2013 - 通过 REST API 获取自定义字段值

问题描述 投票:0回答:2

我有 SPList,其中包含自定义类型列(从 Lookup 继承)。当我尝试通过 REST API 检索其项目时出现错误:

/_vti_bin/client.svc/web/lists/getbyid(guid'list-id')/Items(item-id)

The value for field 'column name' of type 'custom field type' cannot be serialized.

REST API 不支持自定义类型吗?谢谢。

rest sharepoint sharepoint-2013
2个回答
0
投票

可以使用 expand 关键字检索查找字段的值

_api/web/lists/getByTitle('Customers')/items?$select=Title,Affiliation/Id,Affiliation/Title&$expand=Affiliation

你可以在这个博客上找到详细的解释 http://www.andrewconnell.com/blog/simplifying-sharepoint-2013-rest-api

请注意 URL 不同,因为您必须使用 SharePoint 2013 rest API。 您提供的 url 是 SharePoint 2010 使用 Rest API 的方式。虽然它在 2013 年仍然存在。


-2
投票

@Oleg Bul.. 阅读本文并成为专家.. https://msdn.microsoft.com/en-us/magazine/dn198245.aspx :D

帖子中关于您的查询的几个重要部分。

$expand - 指定返回连接列表中的哪些投影字段。

当一个 SharePoint 列表有一个到另一个列表的查找字段时,这实际上充当了两个列表的连接。您可以使用 $expand 选项从连接列表中返回投影字段。例如,如果 Books 列表有一个 PublishedBy 字段查找 Publisher 列表的 Name 字段,您可以使用此 URL 返回这些名称:

_api/web/lists/getByTitle(
  'Books')/items?$select=Title,PublishedBy/Name&$expand=PublishedBy

更新的答案:-

我能想到的可能的解决方案..

  1. 尝试使用 $select='*' 获取所有列
  2. 扩展和部署您自己的 REST 端点关于创建 REST 端点的文章
  3. 创建计算列并尝试按原样复制查找自定义列的值,并在查询中获取计算列。
© www.soinside.com 2019 - 2024. All rights reserved.