Remote execution - Package update via API not working

Our foreman is configured to use remote execution by default in the settings:

Use remote execution by default → Yes

When scheduling a remote command through the web interface (Schedule Remote job), everything works as expected. SSH is used for the communication.

When I try to update packages using the following API command, the command fails:

curl -H “Accept:application/json” -H “Content-Type:application/json” --request PUT --insecure --user user:password https://foreman/api/v2/hosts/50/packages/upgrade_all

error message:
Remote actions using katello-agent are deprecated and will be removed in Katello 4.0. You may consider switching to Remote Execution.

I don’t understand why the “Schedule Remote job” works over remote execution and the API call doesn´t.

Thanks in advance.


I guess this API endpoint is Katello’s old endpoint that only supported katello-agent. To use REX to achieve the same job, you need to use job invocation API directly. UI does that on the background. See https://foreman/apidoc/v2/job_invocations/create.html, you’ll need to specify the job template to use and probably some other inputs.

Thanks, I had a look at the API documentation. But I´m not able to figure out how the JSON body for the API call should look like.

I tried the following command like described in the documentation:

curl -H "Accept:application/json,version=2" -H "Content-Type:application/json" -X POST -u user:password -k -d '{"job_invocation":{"job_template_id":"155","targeting_type":"static_query","search_query":"name ^ (server-01)","command":"Run date", "description_override":"Run date","description_format":"Run date"}}' https://foreman/api/v2/job_invocations

Unfortunately I get the following error message:

  "error": {"message":"Validation failed: Template run command - ssh default: Not all required inputs have values. Missing inputs: command"}

I cant´t find any parameter that handles the needed “command” field.

Does anyone has a valid example JSON body for this?

The command field (name of the input) should be nested within an inputs object. The description fields are optional so you could omit those.

    "job_invocation": {
        "job_template_id": "155",
        "targeting_type": "static_query",
        "search_query": "name ^ (server-01)",
        "command": "Run date",
        "inputs": {
            "command": "date"
        "description_override": "Run date",
        "description_format": "Run date"

Thank you very much it worked.