Project

General

Profile

Actions

Bug #4805

closed

API search method not working for opratingsystem type of objects.

Added by Xavier Naveira over 10 years ago. Updated over 10 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

Trying to retrieve opearating system properties via API an empty set of results is returned when using "?search" method in the url.

Attached the result of calling the following urls:

https://<foreman_server>/api/v2/operatingsystems
https://<foreman_server>/api/v2/operatingsystems?search=CentOS


Files

operatingsystems.htm operatingsystems.htm 1.51 KB Xavier Naveira, 03/24/2014 04:08 PM
operatingsystemssearch.htm operatingsystemssearch.htm 155 Bytes Xavier Naveira, 03/24/2014 04:08 PM
operatingsystemsbyname.htm operatingsystemsbyname.htm 1.51 KB Xavier Naveira, 03/25/2014 07:48 AM
operatingsystemsbyfullname.htm operatingsystemsbyfullname.htm 1.51 KB Xavier Naveira, 03/25/2014 07:48 AM
Actions #1

Updated by Dominic Cleal over 10 years ago

Try using a "attribute = value" style of searching instead of relying on free text search. The same search rules as in the UI (which has a useful auto-complete) apply here, so "name = CentOS" will return all CentOS operating systems.

Updated by Xavier Naveira over 10 years ago

Hi Dominic,

Thank you for your answer.

Unfortunately using "attribute=value" doesn't seem to work either.

When searching using the following urls I get the whole list of operating systems in my Foreman installation (see results attached)

https://<foreman_server>/api/v2/operatingsystems?name=CentOS
https://<foreman_server>/api/v2/operatingsystems?fullname=CentOS 6.3

Another way to search for objects that I'm using successfully when looking for hosts is to use their name in the url like this:

https://<foreman_server>/api/v2/hosts/<name_of_the_server>

So I thought to give it a try and do the same and test:

https://<foreman_server>/api/v2/operatingsystems/CentOS 6.3

But it seems to be a problem with the parsing because the call aboive throws back:

{

"error": {
"message": "Resource operatingsystem not found by id 'CentOS 6'"
}

}

Actions #3

Updated by Dominic Cleal over 10 years ago

The "attribute=value" is still passed within the "search" parameter, sorry that wasn't clear. For example:

https://foreman_server/api/v2/operatingsystems?search=fullname=CentOS 6.3

Have a look at the GUI for a better idea, you'll be able to search for something and reuse the same search string against the API.

The parse issue has been fixed in #4201 for Foreman 1.5.0.

Actions #4

Updated by Xavier Naveira over 10 years ago

Ok, so searching like this:

https://foreman_server/api/v2/operatingsystems?search=fullname=CentOS 6.3

Gives back:

{
"error": {
"message": "Field 'fullname' not recognized for searching!",
"class": "ScopedSearch::QueryNotSupported"
}
}

But I see your point and the parsing issue solved is all that I need.

Thank you for your help! You may now close this issue.

Actions #5

Updated by Dominic Cleal over 10 years ago

  • Status changed from New to Resolved

Oh sorry, I copied your example without reading and checking it. It looks like we don't have a field at the moment for the "fullname", since that area (the concatenated name) is a bit complex and messy. It may be better to search for a specific name, major and minor. Anyway, glad that helped a bit, closing.

Actions

Also available in: Atom PDF