Reply

Issue with objtype field in search object

jmmurrah
Techie
Posts: 5
2107     0

Trying to use the objtype field in a search object to filter the records, and I'm having inconsistent results.  When I use it along with a search_string field like this:

 

https://gridmaster/wapi/v2.2/search?search_string:~=servername&objtype=record:a&_max_results=10

 

it works, and filters on both object type and search string.  But when I try to use it with an address field I get a 400:

 

https://gridmaster/wapi/v2.2/search?address=192.168.1.1&objtype=record:a&_max_results=10

 

I don't see anything in the documentation to suggest the objtype field can only be used with the search_string, but is that the case?  Also it appears using the objtype field by itself returns an error as well.

Re: Issue with objtype field in search object

GHorne Community Manager
Community Manager
Posts: 254
2108     0

'search' comes in 2 forms. If you look at the GUI, you will see that there is 'basic' and 'advanced', but the WAPI docs don't call these out very well.

 

A basic search is across ALL objects, matching one of  ‘address’, ‘mac_address’, ‘duid’ or ‘fqdn’:

/wapi/v2.2/search?address=192.168.1.1

An Advanced search is across one or all objects, and all fields, looking for a string:

# matches any 'A record' with a comment, name or EA containing 'servername'
https://gridmaster/wapi/v2.2/search?search_string:~=servername&objtype=record:a
# matches any object with any field containing 'servername'
https://gridmaster/wapi/v2.2/search?search_string:~=servername

 

 

Search is also used to ONLY search across multiple fields or multiple objects, so your search term is redundant. You could just search the 'record:a' objects:

 

/wapi/v2.2/record:a?ipv4addr=192.168.1.1&_max_results=10

 

 

 

Re: Issue with objtype field in search object

jmmurrah
Techie
Posts: 5
2108     0

Wow, it seems blindingly obvious now that you've pointed it out.  I was so focused on the documentation I didn't even stop to think about what I was actually trying to do.  thanks!

Showing results for 
Search instead for 
Do you mean 

Recommended for You