Microsoft Graph 中的单引号转义 [英] Single quote escaping in Microsoft Graph
问题描述
我正在尝试按 displayName 查询用户,但在通过 C# SDK 和 Graph Explorer 发送请求时转义单引号时遇到问题.
I'm trying to query users by displayName, but I have trouble escaping single quote when sending the request by both C# SDK and Graph Explorer.
更新:示例中不清楚,我遇到问题的搜索词是 I'
Update: It's not clear in the example, the search term I have trouble with is I'
查询示例:https://graph.microsoft.com/v1.0/users?$filter=startsWith(displayName,'I%27') 结果
Status Code: 400
{
"error": {
"code": "BadRequest",
"message": "There is an unterminated string literal at position 28 in 'startsWith(displayName,'I'')'.",
// snip
}
}
我尝试了各种转义,用反斜杠、双引号、%2527
代替引号,没有任何效果.使用报价查询的正确方法是什么?
I tried all sorts of escaping, with backslashes, double quotes, %2527
instead of the quote, nothing works. What's the proper way to query with a quote?
推荐答案
https://graph.microsoft.com/v1.0/users?$filter=startsWith(displayName,'I''')
SQUOTE-in-string = SQUOTE SQUOTE ;两个连续的单引号在字符串文字中表示一个
SQUOTE-in-string = SQUOTE SQUOTE ; two consecutive single quotes represent one within a string literal
这篇关于Microsoft Graph 中的单引号转义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!