1

I have the following query:

[{ "type": "url", "value": ["https://graph.microsoft.com/v1.0/users?$count=true&$search="displayName:room"&$filter=endsWith(mail,'microsoft.com')&$orderBy=displayName&$select=id,displayName,mail"]}]

On running the below code with input as the above query:

JToken.Parse(string query);

I see Invalid JSON query exception

I updated the query to use single quotes for 'displayName:room':

[{ "type": "url", "value": ["https://graph.microsoft.com/v1.0/users?$count=true&$search='displayName:room'&$filter=endsWith(mail,'microsoft.com')&$orderBy=displayName&$select=id,displayName,mail"]}]

With this change, I see Message: Syntax error: character ''' is not valid at position 0 in ''displayName:room'' on making graph call with the url. What am I missing?

user989988
  • 3,006
  • 7
  • 44
  • 91
  • 1
    How to escape quotes inside a string depends on what exactly you feed that string to. URLs normally use percent encoding: single-quote is replaced with the 3 characters "%27", double-quote is replaced with the 3 characters "%22". In other situations, doublequote is replaced with 2 characters backslash-doublequote. Related: "[How to escape double quotes in JSON](https://stackoverflow.com/questions/15637429/how-to-escape-double-quotes-in-json)". – David Cary Sep 21 '22 at 04:31

0 Answers0