Automic Workload Automation

 View Only
Expand all | Collapse all

[12.3] Importing jobs using REST API

  • 1.  [12.3] Importing jobs using REST API

    Posted Feb 07, 2020 08:50 AM
    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

    Broadcom Employee
    Posted Feb 07, 2020 10:06 AM
    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 Feb 07, 2020 10:21 AM
    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

    Broadcom Employee
    Posted Feb 07, 2020 10:53 AM
    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 Feb 07, 2020 12:01 PM
    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

    Broadcom Employee
    Posted Feb 10, 2020 02:01 AM
    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 Feb 13, 2020 05:20 AM
    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

    Broadcom Employee
    Posted Feb 13, 2020 05:57 AM
    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
    ------------------------------



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

    Posted Jan 20, 2021 05:40 PM
    Hi 
    I am also trying to use rest api to import jobs and workflows as well. While importing workflows, I want to add jobs and dependencies. But dependency part is really hard beacuse with every line_condition I have maintain line_number of the links across the workflow. While importing workflows as xml there is no issue because all I need to do is to add new line to predecessor tag and this line contains only the line number of current job and predecessor job. No need to add the line number of link.
    Since there is no plan to support xml in rest api, could you help me with easily update the workflow through the rest api please?
    Thanks 
    
    
    
    



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

    Posted Mar 08, 2021 03:20 AM
    Hi,
    We also trying use REST api to change objects.
    Is there a way to change VARA objects through POST requests?

    Thank you,
    Regards Omer

    ------------------------------
    Product Manager
    Ness technologies
    ------------------------------



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

    Broadcom Employee
    Posted Mar 09, 2021 03:14 AM
    Hi Omer,

    try using /{client_id}/scripts  and run

    {
      "script": ":PUT_VAR '<VARA>','<Key>','<Value>'",
      "queue": "CLIENT_QUEUE"
    }