Need help on adding Encoded Query to REST URL

Rajanmehta
Mega Guru

Hello,

How do I add Encoded multiple AND query in URL?

Following is Encoded Query.

"companyLIKEindia^model_category!=6d593627db9d4b44386879531f9619c0^model_category!=cd49b227db9d4b44386879531f9619e9"

var url = https://xxxx.service-now.com/api/now/table/alm_hardware?sysparm_display_value=true&sysparm_exclude_reference_link=true&sysparm_limit=20000 &sysparm_fields=sys_id%2Cassigned_to";

Please advise.

Thanks.

1 ACCEPTED SOLUTION

Hello,

That error appears to be related to some other part of your code, not what I'm answering in this post.

You can comment out the url components and see if the error still occurs, if so, then it's related to something else.

I'm merely covering a url that is assigned to a variable as string and concatenating the sysparm_query piece on to it.

I know when I copied your script before...you had a space in your url...and it appears you didn't copy and paste what I posted...so maybe that's an issue.

var url = https://xxxx.service-now.com/api/now/table/alm_hardware?sysparm_display_value=true&sysparm_exclude_reference_link=true&sysparm_limit=20000 &sysparm_fields=sys_id%2Cassigned_to";

Please review the script I posted...

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

5 REPLIES 5

Hi Allen,

I was able to figure that out finally. We need to format as below for encoded query.

Replace ^ with %5E, then it is working fine.

var encQuery = "companyLIKEindia%5Emodel_category!=6d593627db9d4b44386879531f9619c0%5Emodel_category!=cd49b227db9d4b44386879531f9619e9";

 

Thanks.