Issues with escaping DoubleQuotes in session relevance with REST API

I’m having a similar issue:

https://iem:52311/api/query?relevance=(name of it) of bes fixlets whose (relevance of it as lowercase contains “name of operating system as lowercase contains “win””) 

The challenge is making the quotes within the quotes literal and I haven’t found a way to get it to work. Can anyone help?


Related: SOLVED: How do I get a DoubleQuote in a session relevance result using the rest api

I think it all has to be in quotes as well to do that, which means it is more like this:

https://iem:52311/api/query?relevance="(name of it) of bes fixlets whose (relevance of it as lowercase contains "name of operating system as lowercase contains "win"")"

Also, you had smart quotes in there, which is another problem entirely. Don’t store things like this in MS Word or similar.

I think the query has to be something like this:

https://iem:52311/api/query?relevance="(name of it) of bes fixlets whose (relevance of it as lowercase contains %22name of operating system as lowercase contains %2522win%2522%22)"

Depending on how you are sending the query, you might have to escape the spaces as well.

It looks like when you pass in a relevance query, it puts quotes around it automatically, but neither of your example worked for me.

source:
(name of it) of bes fixlets whose (relevance of it as lowercase contains “name of operating system as lowercase contains “win””)

output:

<BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
<Query Resource="(name of it) of bes fixlets whose (relevance of it as lowercase contains "name of operating system as lowercase contains "win"")">
<Result/>
<Error>The operator "win" is not defined.</Error>
</Query>
</BESAPI>

source with %2522:

(name of it) of bes fixlets whose (relevance of it as lowercase contains %22name of operating system as lowercase contains %2522win%2522%22)"

output:

<BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
<Query Resource="(name of it) of bes fixlets whose (relevance of it as lowercase contains "name of operating system as lowercase contains "win"")"">
<Result/>
<Error>The operator "win" is not defined.</Error>
</Query>
</BESAPI>

I think that depends on the method you are using. I don’t know how you are doing this.

If the first part was true that it puts quotes around it automatically, then neither example would work.

Try this:

(name of it) of bes fixlets whose (relevance of it as lowercase contains “name of operating system as lowercase contains %22win%22”)

You should be able to get the Session Relevance query working in the Session Relevance Tester, or Presentation Debugger, or WebReports QnA first, then try to do that same query using the REST API.

Also, generally you should be able to look for Windows in the name of the fixlet to see if it is applicable on Windows machines. You could also use the site if you are looking for items in the Patches for Windows site.

Ultimately I’m executing a curl GET against the URL, but for testing, I’m just dumping the URL into a browser (and getting the same results).

What you suggested does work in WebReports QnA debugger for me. But when I put it into a URL, the double parenthesis break it.

In the attachment, you can see that when it is called in a browser, quotes are automatically generated around it.

Try this:

(name of it) of bes fixlets whose (relevance of it as lowercase contains “name of operating system as lowercase contains %2522win%2522”)

Essentially, whatever ends up in the

<Query Resource="">

needs to run in the WebReports QnA debugger without modification.

I can tell from your screenshot that the double quotes around win are not escaped correctly.

zero results for that relevancy in WebReports QA. if I take out the 25 and leave %22, it works in QA.

In the browser,

https://:52311/api/query?relevance=(name%20of%20it)%20of%20bes%20fixlets%20whose%20(relevance%20of%20it%20as%20lowercase%20contains%20%22name%20of%20operating%20system%20as%20lowercase%20contains%20%2522win%2522%22)

output:

<BESAPI xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="BESAPI.xsd">
<Query Resource="(name of it) of bes fixlets whose (relevance of it as lowercase contains "name of operating system as lowercase contains "win"")">
<Result/>
<Error>The operator "win" is not defined.</Error>
</Query>
</BESAPI>

Try this:

(name of it) of bes fixlets whose (relevance of it as lowercase contains "name of operating system as lowercase contains %252522win%252522")

I am not recollecting correctly, try - " or %22

jgstew, this worked:

https://iem:52311/api/query?relevance=(name of it) of bes fixlets whose (relevance of it as lowercase contains "name of operating system as lowercase contains %252522win%252522")

thank you very much.

1 Like

Glad this worked:

It isn’t obvious, which makes it hard to solve.

1 Like