【问题标题】:Can't get SharePoint fields with Java lib msgraph-sdk-java-dev for drive item with parenthesis in name无法使用 Java lib msgraph-sdk-java-dev 获取名称中带括号的驱动器项的 SharePoint 字段
【发布时间】:2019-03-18 21:36:01
【问题描述】:

我正在尝试访问与我的 Office 365 根目录 (https://www.office.com/) 中名为 (1).docx 的文件关联的字段 从 Java 库访问时,URL 中的左括号会导致一些问题从 Graph Explorer 中很好。

使用 Microsoft Graph Explorer,我可以通过将文件名作为参数传递给子级来访问它,如下所示:

https://graph.microsoft.com/v1.0/me/drive/root/children('(1).docx')

从 msgraph-sdk-java-dev 中,IDriveItemRequestBuilder 有一个接受字符串参数的子方法。

这不会尝试将其作为参数传递给 children(),而是附加一个斜杠,后跟类似的名称

...drive/root/children/%281%29.doc

实际上.. 我对 () 进行了编码。这两种方法都不起作用。

有没有办法让 IDriveItemRequestBuilder 使用其他形式的访问子项?或者我应该以其他方式访问该项目吗?

最终......我需要访问与该项目相关的字段,如下所示: https://graph.microsoft.com/v1.0/me/drive/root/children('(1).docx')/listitem/fields

【问题讨论】:

    标签: sharepoint microsoft-graph-api


    【解决方案1】:

    我能够通过继承 DriveItemRequestBuilder 并覆盖 children(String id) 来解决这个问题

    driveItemReqBldr = new DriveItemRequestBuilder(driveItemReqBldr.getRequestUrl(), driveItemReqBldr.getClient(), null) {
        public IDriveItemRequestBuilder children(String id) {
            return new DriveItemRequestBuilder(getRequestUrlWithAdditionalSegment("children") + "('" + id +"')", getClient(), null);
        }
    };
    

    不确定是否是最好的方法,但它确实有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-15
      相关资源
      最近更新 更多