如何在图形查询中引用冒号 [英] How to quote colons in graph query

查看:69
本文介绍了如何在图形查询中引用冒号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些代码可以获取 SharePoint 网站中列表的详细信息,然后想查明同名列表是否仍然存在.这工作正常,除了包含冒号的列表名称 - 我发现 Graph 误解了冒号并破坏"了 URL.

I have some code which gets details of lists in a SharePoint site then later wants to find out if a list with the same name still exists. This works fine except for list names that contain a colon - I find Graph misinterprets the colon and 'corrupts' the URL.

例如,在 Graph Explorer 中,当我给它以下查询时:

For instance, in Graph Explorer when I give it the following query:

https://graph.microsoft.com/v1.0/sites('mysite.sharepoint.com,aa-aa-aa,bb-bb-bb')/lists('19:abcdef@thread.tacv2_wiki')

错误响应在消息"属性中包含以下内容:

The error response contains the following in the 'message' property:

The expression \"sites('mysite.sharepoint.com,aa-aa-aa,bb-bb-bb')/lists('19')/abcdef@thread.tacv2_wiki\" is not valid. 

请注意,它拆分了原始 URL,认为冒号是路径中新段的开始,即使它在引号内.

Note that it's split the original URL, thinking the colon is the start of a new segment in the path, even though it's inside a quote.

我尝试了各种引用冒号(%3A 和 %253A 和 %25253A)和不同风格的引号字符,但它们要么返回相同的错误,要么给出解析错误.

I've tried all sorts of quoting of the colon (%3A and %253A and %25253A) and different styles of quote characters, but they all either return the same error or give a parsing error.

更多信息 - 我特别想按名称而不是按原始 ID 进行搜索(这会更容易),我实际上在代码中使用了 Graph Managed API,但它会产生相同的错误(您认为它会在内部知道如何引用),该列表实际上是在 Teams 站点中创建的用于管理频道信息的隐藏列表.

More information - I specifically want to search by name not by original id (which would be much easier), I'm acutually using Graph Managed API in code but it generates the same error (you'd think it would internally know how to quote), the list is actually a hidden one created in a Teams site to manage channel information.

推荐答案

我也能够重现您的问题,但作为一种变通方法,您可以使用过滤器查询参数通过使用以下查询来获取列表.

I was also able to reproduce your issue but as a work around you can use the filter query parameter to get the list by using below query.

https://graph.microsoft.com/v1.0/sites/soaadteam.sharepoint.com,c1178396-d845-46fa-bc0c-453d2951dad5,19ee9a1e-001d-48f1-9ee8-b0adfde54e45/lists?$filter=displayName eq '19:abcdef@thread.tacv2_wiki'

这篇关于如何在图形查询中引用冒号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆