Problems with API using LIKE parameter

StevenAgFirst
Tera Contributor

Hello,

I am trying to access a table certificate_domain with a parameter of GET command:

 

GET https://environment.service-now.com/api/now/table/certificate_domain?sysparm_query=domainLIKExxxxxxx... 

where xxxxx's are the hostname I am looking for.

 

Issuing this command in API explorer returns the correct two records. No problems.

 

When I execute this using the API and Visual Basic code, it returns nothing and a response code of 403. When I change the Visual Basic code to have an '=' sign instead of the 'LIKE"' in the query, it returns 1 record and all is good (response code 200). However, I need all the records because some have the xxxxxx.company.net suffix on them and I want them also.

 

I can't figure out what I am doing wrong. If the command works in the API Explorer, it should work in the Visual Basic program. 

 

I appreciate anything you can tell me. Thank you in advance.

5 REPLIES 5

Thank you Viraj and Ankur for your responses. 

 

I have tried multiple methods to try to get the records I am looking for, none have worked except not putting any parameters on the GET request. If I leave off all parameters, I get the entire table back and response code 200. This means that I do have authority to read the table so security is not an issue unless the LIKE command needs some security level I am not aware of.

As to encoding, I have tried:

?sysparm_query=domain=UC4PMWEB04    <- it returns the record I want

?sysparm_query=domain%3DUC4PMWEB04     <- it returns the record I want

?sysparm_query=domainLIKEUC4PMWEB04     <- Errors out

?sysparm_query=domain%20LIKE%20UC4PMWEB04     <- Errors out

 

I have tried these in the API Explorer and they work (have not tried the last one since the 3rd one without the spaces worked fine and returned what I wanted).

 

There really is nothing to encode on this statement so I don't think that is it. I also hard coded it instead of using variables to verify that there are no special characters in it and it still fails.

It acts like there is a bug in the API that just does not like the LIKE command. I have tried everything I can think of to get it to work and nothing works. I would put the code here but it uses a DLL Class that I built to do the reads. I use the code in many different programs to read data out of just about most of the CMDB tables with no issues so I know it works, just not for this table. 

 

Thank you.

Steven