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

查看:70
本文介绍了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天全站免登陆