Automic Workload Automation

Expand all | Collapse all

[12.3] Importing jobs using REST API

Jump to Best Answer
  • 1.  [12.3] Importing jobs using REST API

    Posted 17 days ago
    Hi
    I'm using AWA 12.3 and trying to use the REST api to import objects.

    I managed to export objects like this :
    curl -H "authorization: Basic xxxxx" -X GET 'http://host:port/ae/api/v1/3500/objects/MYTESTJOB'

    I get the following output :
    {
    "total" : 1,
    "data" : {
    "jobs" : {
    "metadata" : {
    "version" : "12.3.0"
    },
    "general_attributes" : {
    "minimum_ae_version" : "11.2",
    "auto_deactivation" : "A",
    "child_flags" : "00000000000000000000000000000000",
    "ert" : "1",
    "platform" : "UNIX",
    "last_runtimes" : "AQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAA==",
    "max_parallel_action" : "1",
    "mrt_time" : "000000",
    "name" : "MYTESTJOB",
    "type" : "JOBS",
    "inherit_output_filter" : "N",
    "queue" : "UC4_TEST",
    "description" : "Test the REST API",
    "versioning_id" : "-1247814801"
    },
    "job_attributes" : {
    "platform" : "UNIX",
    "agent" : "xxxx",
    "login" : "xxxx",
    "job_report_path" : "2",
    "priority" : "0",
    "unix_shell" : "bash",
    "unix_shell_options" : "",
    "unix_type" : "B",
    "unix_cmd" : "hostname"
    }
    }
    },
    "path" : "TEST/RESTAPI",
    "hasmore" : false
    }​
    I can save this output to a file (output.json), then give it back to the AE :
    curl -H "authorization: Basic xxxxxxxxxxxxxx" -X POST 'http://host:port/ae/api/v1/3500/objects' -d @./export.json
    {
    "code" : 45106,
    "error" : "The request is invalid and cannot be processed by the Automation Engine.",
    "details" : "No detail information available."
    }

    If I pass the string as pyaload instead of the file, I get the same error.
    Any idea what I'm missing ?
    Any way I can troubleshoot this ?

    Thanks !


  • 2.  RE: [12.3] Importing jobs using REST API

    Posted 17 days ago
    HI,
    the JSON Export of the REST API also exports also runtime data of the object. These runtime data belongs to this specific object and won't work with the new object.These information have to removed in order to create a new object based on the exported information
    Please remove from the export following properties
    * "last_runtimes"
    * "hasmore" -> You may keep it, if you want to create more than one object
    * "child_flags"
    With v12.3 we have changed the default for overwriting existing objects.
    You you to add the following query parameter to the POST url to overwrite the object
    ?overwrite_existing_objects=true

    ------------------------------
    Sr. Solution Architect
    Broadcom
    ------------------------------



  • 3.  RE: [12.3] Importing jobs using REST API

    Posted 17 days ago
    Hi, and thanks for the answer.

    I have removed the 3 lines from the input file, but I still get the same error.


  • 4.  RE: [12.3] Importing jobs using REST API

    Posted 17 days ago
    HI,
    you have also remove
    '"total": 1,
    as all and make sure that the JSON structure is still valid.

    ------------------------------
    Sr. Solution Architect
    Broadcom
    ------------------------------



  • 5.  RE: [12.3] Importing jobs using REST API

    Posted 17 days ago
    I removed the line, made sure JSON is still valid, and still I get the same error


  • 6.  RE: [12.3] Importing jobs using REST API

    Posted 14 days ago
    HI,
    please double check the JSON structure.  Make sure that all the colons and comma are on the right place,
    Note that the very last JSON element should not have a comma at the end.

    ------------------------------
    Sr. Solution Architect
    Broadcom
    ------------------------------



  • 7.  RE: [12.3] Importing jobs using REST API
    Best Answer

    Posted 11 days ago
    Hi

    I finally got it. I was missing the headers parameters :
    -H "Content-Type: application/json" -H "Accept: application/json"

    Now I get the code 200 and object gets imported.
    However, there is no message in the body but I can cope with it.

    Any chance that the REST API can handle XML files like UC4 always did ?

    Thanks for your help anyway


  • 8.  RE: [12.3] Importing jobs using REST API

    Posted 11 days ago
    there are currently no plans to support XML in the REST API.
    REST is primarily a JSON driven. Embedded XML structure does not improve the readability of the calls

    ------------------------------
    Sr. Solution Architect
    Broadcom
    ------------------------------