Automic Workload Automation

 View Only

Expand all | Collapse all

Inconsistent success in setting and returning current values of the Maximum Resource setting using the REST API

  • 1.  Inconsistent success in setting and returning current values of the Maximum Resource setting using the REST API

    Posted Jan 07, 2026 04:14 PM

    After receiving answers to my questions about how to set the value of the Maximum Resource setting in Automic Automation, I've been using the following code (Python) to do that:

    json_payload = {
            "script": f":SET_UC_SETTING WORKLOAD_MAX, \'{agent}\', {value}"
    }
    response = post_api(f"/ae/api/v1/{use_client}/scripts", json.dumps(json_payload), auth, "agent")

    As I run this code, I am finding that this call periodically fails to set the value.  Because of that, I wrote the following code that would be called after this code to return the value of the Maximum Resources setting and compare it with what it was supposed to set it to. The call to
    /ae/api/v1/{use_client}/executions/{run_id}/reports/ACT often results in the following error. I've checked in the UI and the run_id that is being used in this call is present as is the Activation text containing the value of Maximum Resources (2026-01-07 13:40:21 - U00020408 Max JOB resources: 0000000000000000). Is this how the rest of you do this kind of verification that changes have been made properly via the REST API? Can anyone see where I may be going wrong?
    2026-01-07 13:58:12,235 [ERROR] API request failed: 404 Client Error: Not Found for url: <end_point>/ae/api/v1/8151/executions/2132072/reports/ACT; status=404; body={
      "code" : 45109,
      "error" : "The requested resource cannot be found.",
      "details" : "No detail information available."
    }

    def get_resources(agent: str, use_client: str, auth: tuple) -> int:
        json_payload = {
            "script": f":SET &maxJob# = GET_UC_SETTING(\"WORKLOAD_MAX_JOB\", \"{agent}\", \"\")\n:PRINT \"Max JOB resources: &maxJob#\""
        }
        response = post_api(f"/ae/api/v1/{use_client}/scripts", json.dumps(json_payload), auth, "agent")
        # post_api now returns a requests.Response on success or None on failure
        if response is None:
            logging.error(f"POST to /scripts failed for client {use_client} when checking resources for agent {agent}.")
            return -1
        if not hasattr(response, "json"):
            logging.error("post_api did not return a Response object with .json(); cannot parse run_id")
            return -1
        try:
            data = response.json()
        except ValueError:
            logging.error("Response body was not valid JSON")
            return -1
        run_id = data.get("run_id")
        if not run_id:
            logging.error(f"No run_id returned from script execution for agent {agent}. Response: %s", json.dumps(data))
            return -1
        response = get_api(f"/ae/api/v1/{use_client}/executions/{run_id}/reports/ACT", auth)
        if response and "data" in response:
            line = response["data"][0].get("content", "")
            if "Max JOB resources:" in line:
                parts = line.split(":")
                if len(parts) == 4:
                    try:
                        value = int(parts[3].strip())
                        return value
                    except ValueError:
                        logging.error(f"Failed to convert resource value to int: {parts[3].strip()}")

        return -1


    -------------------------------------------


  • 2.  RE: Inconsistent success in setting and returning current values of the Maximum Resource setting using the REST API

    Broadcom Employee
    Posted Jan 08, 2026 01:42 AM

    Hi,

    the /scripts endpoint runs the script provided asynchronously. Maybe the execution was not finished yet but you already want to fetch the ACT report. Maybe you can add an additional step in between to check whether the returned runid has finished processing before continuing. Or try adding a wait time before fetching the ACT report as a quick and dirty workaround.

    Regards, Markus

    -------------------------------------------