【问题标题】:Whats the sharepoint rest endpoint to get a web by its id什么是通过 id 获取网络的共享点休息端点
【发布时间】:2015-03-19 10:07:27
【问题描述】:

我在共享点页面中有一个 webid 和一个 listid。我正在尝试构建一个休息网址以进入列表。

在给定 WebID 的情况下,我无法确定获取网络的 url。

我试过了 https://xxxx.sharepoint.com/_api/web/webs(guid'33213c5c-30e5-468c-87f7-52b48a7b6a3d') https://xxxx.sharepoint.com/_api/web/webs('33213c5c-30e5-468c-87f7-52b48a7b6a3d') https://xxxx.sharepoint.com/_api/web/webs/GetById('33213c5c-30e5-468c-87f7-52b48a7b6a3d')

我如何使用该 ID 访问网络?我需要在网络上获取一个列表。 我在想它会很简单 https://xxxx.sharepoint.com/_api/web/webs(guid'33213c5c-30e5-468c-87f7-52b48a7b6a3d')/lists(guid'the-list-id'),但我无法上网!

++++++++++++++++++ m回复vadim ++++++++++++++++++++++++

感谢瓦迪姆, 你让我指出了正确的方向

这个网址可以让我上网: https://xxx.sharepoint.com/_api/web/webs?$filter=iD eq guid'33213c5c-30e5-468c-87f7-52b48a7b6a3d'

这个 url 将获取所有网站中所有列表中的所有项目 https://xxx.sharepoint.com/_api/web/webs?$expand=lists,lists/items

此 url 将获取指定网站中所有列表中的所有项目: https://xxx.sharepoint.com/_api/web/webs?$expand=lists,lists/items&$filter=iD eq guid'33213c5c-30e5-468c-87f7-52b48a7b6a3d'

但是如何获取指定网站中指定列表中的所有项目? 这不起作用: https://xxx.sharepoint.com/_api/web/webs?$expand=lists,lists/items&$filter=((iD eq guid'33213c5c-30e5-468c-87f7-52b48a7b6a3d') and (Lists/Id eq guid'd38444af-dd7f-404b-9e75-b1f8c6cdee7d' ))

它是一个有效的 Web id 和一个有效的列表 id,但 sharepoint 抱怨 :m:message xml:lang="en-US">字段或属性“Id”不存在。

有什么想法吗?

【问题讨论】:

    标签: rest sharepoint-2013


    【解决方案1】:

    可以使用$filter 查询选项检索Web 资源,如下所示:

    /_api/web/webs?$filter=ID eq guid'c01e1b4a-e671-431d-97aa-4b02a57803c7'
    

    为了通过 id 检索相应的 List 资源,您可以考虑以下方法:

    1. 执行请求以通过其 ID 获取 Web Url: /_api/web/webs?$select=ServerRelativeUrl&$filter=ID eq guid'c01e1b4a-e671-431d-97aa-4b02a57803c7'
    2. 通过 id 获取列表:{web url}/_api/Web/Lists(guid'b778bbec-dd69-4a6c-9437-c73972c36292')

    {web url} 是在第一个请求中找到的网站网址

    【讨论】:

    • 感谢 vadim,堆栈溢出不会让我发表评论,因为它太长了。我在原始问题中添加了我的评论。
    • 此答案假定 web guid 与子 web 相关。如果 web 可能是子站点的子站点或根站点,则它不会返回 WebURL。以下答案中概述的方法可能更合适。 stackoverflow.com/a/51625516/247298
    猜你喜欢
    • 1970-01-01
    • 2020-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-23
    • 2021-06-21
    • 2013-02-17
    • 1970-01-01
    相关资源
    最近更新 更多