search cancel

Import Folder in Version 21.0 REST API

book

Article ID: 228614

calendar_today

Updated On:

Products

CA Automic One Automation

Issue/Introduction

Here is a POST script to import a folder and all its contents via the REST API into an existing client.  In this case, the folder should be REST/EXAMPLES/FOLDEROBJECTS and it will have two objects inside it, JOB3 and JOB4

POST {{URLROOT}}://{{HOSTNAME}}:{{PORT}}/{{APIURL}}/{{APIVERSION}}/{{CLIENT}}/folderobjects

Here is the content of the json script:

{
  "data" : [ {
    "data" : {
      "fold" : {
        "metadata" : {
          "version" : "21.0.0"
        },
        "general_attributes" : {
          "type" : "FOLD",
          "name" : "REST/EXAMPLES/FOLDEROBJECTS"
        }
      }
    },
    "path" : ""
  }, {
    "data" : {
      "jobs" : {
        "metadata" : {
          "version" : "21.0.0"
        },
        "general_attributes" : {
          "type" : "JOBS",
          "name" : "JOB3",
          "max_parallel_action" : 1,
          "mrt_time" : "000000",
          "inherit_output_filter" : "N",
          "platform" : "WINDOWS",
          "queue" : "CLIENT_QUEUE",
          "auto_deactivation" : "A",
          "minimum_ae_version" : "11.2"
        },
        "job_attributes" : {
          "agent" : "<WIN>",
          "job_report_path" : "2",
          "platform" : "WINDOWS",
          "win_report_by_script" : "0",
          "win_work_dir" : "c:\\",
          "win_view" : "0",
          "win_logon_as_batch" : "0",
          "job_object" : "",
          "win_cmd" : "",
          "win_typ" : "0",
          "win_show_at_desktop" : "0"
        },
        "scripts" : [ {
          "process" : [ "! insert these lines in your script to determine if an error occurred", "!", "! @set retcode=%errorlevel%", "! @if NOT %ERRORLEVEL% == 0 goto :retcode", null ]
        } ]
      }
    },
    "path" : "REST/EXAMPLES/FOLDEROBJECTS"
  }, {
    "data" : {
      "jobs" : {
        "metadata" : {
          "version" : "21.0.0"
        },
        "general_attributes" : {
          "type" : "JOBS",
          "name" : "JOB4",
          "max_parallel_action" : 1,
          "mrt_time" : "000000",
          "inherit_output_filter" : "N",
          "platform" : "WINDOWS",
          "queue" : "CLIENT_QUEUE",
          "auto_deactivation" : "A",
          "minimum_ae_version" : "11.2"
        },
        "job_attributes" : {
          "agent" : "<WIN>",
          "job_report_path" : "2",
          "platform" : "WINDOWS",
          "win_report_by_script" : "0",
          "win_work_dir" : "c:\\",
          "win_view" : "0",
          "win_logon_as_batch" : "0",
          "job_object" : "",
          "win_cmd" : "",
          "win_typ" : "0",
          "win_show_at_desktop" : "0"
        },
        "scripts" : [ {
          "process" : [ "! insert these lines in your script to determine if an error occurred", "!", "! @set retcode=%errorlevel%", "! @if NOT %ERRORLEVEL% == 0 goto :retcode", null ]
        } ]
      }
    },
    "path" : "REST/EXAMPLES/FOLDEROBJECTS"
  } ]
}

Environment

Release : 12.3

Component :

Resolution

See also: AE REST API documentation

POST/{client_id}/folderobjects Import objects to a target folder

Additional Information

For an example of exporting a folder and its objects, please see the article: Export folder in version 21 REST API