我正在尝试通过displayName查询用户,但在通过C#SDK和Graph Explorer发送请求时,我无法转义单引号。
更新:在示例中不清楚,我遇到问题的搜索字词为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
而不是引号,没有任何效果。查询报价的正确方法是什么?
答案 0 :(得分:6)
https://graph.microsoft.com/v1.0/users?$filter=startsWith(displayName,'I''')
SQUOTE-in-string = SQUOTE SQUOTE;连续两个单引号 在字符串文字中表示一个