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?
No escaping is used with single quotes. Use a double backslash as the escape character for backslash.
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? Batching reduces the number of round trips an application makes to Microsoft Graph by submitting multiple requests in one HTTP round trip.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With