Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single quote escaping in Microsoft Graph

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.

Update: It's not clear in the example, the search term I have trouble with is I'

Example query: https://graph.microsoft.com/v1.0/users?$filter=startsWith(displayName,'I%27') results in

Status Code: 400
{
    "error": {
        "code": "BadRequest",
        "message": "There is an unterminated string literal at position 28 in 'startsWith(displayName,'I'')'.",
        // snip
    }
}

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?

like image 205
Jakub Tománek Avatar asked Jan 05 '17 17:01

Jakub Tománek


People also ask

How do you escape a single quote?

No escaping is used with single quotes. Use a double backslash as the escape character for backslash.

How do you escape a single quote in power automate?

If you think through the logic here, to escape a single quote in a string you need to use two single quotes, we need the result to have 2 single quotes, so that's 4 single quotes and then you wrap the replace string in the expression with another 2 single quotes.

Which of the following statements is true about the batch request support in Microsoft Graph?

Which of the following statements is true about the batch request support in Microsoft Graph? Batching reduces the number of round trips an application makes to Microsoft Graph by submitting multiple requests in one HTTP round trip.


1 Answers

https://graph.microsoft.com/v1.0/users?$filter=startsWith(displayName,'I''') 

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

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

like image 168
Marek Rycharski Avatar answered Nov 15 '22 10:11

Marek Rycharski