Applicable patching data details through API

Problem: looking for an API call for getting details of Applicable patching data of all hosts from each organization

Expected outcome: All Hosts Applicable patching data to show

Foreman and Proxy versions: 3.4.0 and 3.4.0

Foreman and Proxy plugin versions: 3.4.0 and 3.4.0

Distribution and version:

Other relevant data:
I see the details when go to Hosts → content hosts. wanted to get the details of patching data applicable to update in the hosts.

I am not sure how these API endpoints work (never used them myself) but you might want to take a look at:
POST /api/hosts/bulk/applicable_errata
POST /api/hosts/bulk/installable_errata
According to the API docs, these should do what you are looking for on a per-organization basis.
As with all content-related things, afaik there is no way to do this cross-organization, so you will have to iterate over all your organizations with these API calls.

I’m getting below error. not sure how to mention all hosts in the organization.

{

"displayMessage": "No hosts have been specified.",

"errors": [

    "No hosts have been specified."

]

}

API doc says you can use included[search] with a search value. If you use a search that matches all hosts (like organization = ) I would assume it should work.
btw, just in case you didn’t know already: You can find the API doc for your Foreman version and all your installed plugins at https://yourforeman.example.com/apidoc

i see the full errata applicable to install for all the hosts, but not seeing the host info which the errata would need to apply.

may i know how to get all hosts patching data from the specific organization?

I have just tested this, and I get a “applicable_hosts” value for each errata (when querying the applicable_errata endpoint).
Here is the curl I used:

curl -k "https://myforeman.example.com/api/hosts/bulk/applicable_errata?per_page=1000" -X POST -H "Content-Type: application/json" -d '{"organization": "myorg, "included": {"search": "name ~ %"}}' -u myuser

Is this not what you are looking for?

great, i have tried * in included[search] via postman using POST URL https://myforeman.example.com/api/hosts/bulk/applicable_errata?organization_id=31&included[search]=*

worked just fine, thanks much.

is there a way to get the application patching data from foreman database?

There is for sure a way, though you will probably have to write that SQL statement from hand. All the information should be in the database somewhere, but I don’t know if some parts might be only stored in the pulp database.