Microsoft Graph 中的单引号转义 [英] Single quote escaping in Microsoft Graph

查看:16
本文介绍了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''') 

基于 http://docs.oasis-open.org/odata/odata/v4.0/errata02/os/complete/abnf/odata-abnf-construction-rules.txt:

SQUOTE-in-string = SQUOTE SQUOTE ;两个连续的单引号在字符串文字中表示一个

SQUOTE-in-string = SQUOTE SQUOTE ; two consecutive single quotes represent one within a string literal

这篇关于Microsoft Graph 中的单引号转义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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