Chilkat Online Tools

Go / Orchestrator / Jobs - Start job with inputs

Back to Collection Items

    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    http := chilkat.NewHttp()
    var success bool

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "startInfo": {
    //     "ReleaseKey": "5b754c63-5d1a-4c37-bb9b-74b69e4934bf",
    //     "Strategy": "Specific",
    //     "RobotIds": [
    //       1553
    //     ],
    //     "NoOfRobots": 0,
    //     "Source": "Manual",
    //     "InputArguments": "{\"greeting\":\"Aloha\"}"
    //   }
    // }

    json := chilkat.NewJsonObject()
    json.UpdateString("startInfo.ReleaseKey","5b754c63-5d1a-4c37-bb9b-74b69e4934bf")
    json.UpdateString("startInfo.Strategy","Specific")
    json.UpdateInt("startInfo.RobotIds[0]",1553)
    json.UpdateInt("startInfo.NoOfRobots",0)
    json.UpdateString("startInfo.Source","Manual")
    json.UpdateString("startInfo.InputArguments","{\"greeting\":\"Aloha\"}")

    http.SetRequestHeader("Content-Type","application/json")
    // Adds the "Authorization: Bearer <access_token>" header.
    http.SetAuthToken("<access_token>")
    http.SetRequestHeader("X-UIPATH-OrganizationUnitId","{{folderId}}")
    http.SetRequestHeader("X-UIPATH-TenantName","{{tenantName}}")

    resp := http.PostJson3("https://domain.com/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs","application/json",json)
    if http.LastMethodSuccess() == false {
        fmt.Println(http.LastErrorText())
        http.DisposeHttp()
        json.DisposeJsonObject()
        return
    }

    sbResponseBody := chilkat.NewStringBuilder()
    resp.GetBodySb(sbResponseBody)

    jResp := chilkat.NewJsonObject()
    jResp.LoadSb(sbResponseBody)
    jResp.SetEmitCompact(false)

    fmt.Println("Response Body:")
    fmt.Println(*jResp.Emit())

    respStatusCode := resp.StatusCode()
    fmt.Println("Response Status Code = ", respStatusCode)
    if respStatusCode >= 400 {
        fmt.Println("Response Header:")
        fmt.Println(resp.Header())
        fmt.Println("Failed.")
        resp.DisposeHttpResponse()
        http.DisposeHttp()
        json.DisposeJsonObject()
        sbResponseBody.DisposeStringBuilder()
        jResp.DisposeJsonObject()
        return
    }

    resp.DisposeHttpResponse()

    // Sample JSON response:
    // (Sample code for parsing the JSON response is shown below)

    // {
    //   "@odata.context": "https://beta.uipath.com/odata/$metadata#Jobs",
    //   "value": [
    //     {
    //       "Key": "b618cdfd-8714-4dbf-9a00-0586a8953c90",
    //       "StartTime": null,
    //       "EndTime": null,
    //       "State": "Pending",
    //       "Source": "Manual",
    //       "SourceType": "Manual",
    //       "BatchExecutionKey": "abbbb5de-d46a-4b9b-8f73-8a3247be0a0e",
    //       "Info": null,
    //       "CreationTime": "2018-09-21T13:28:31.1449691Z",
    //       "StartingScheduleId": null,
    //       "ReleaseName": "Heyyo_playground",
    //       "Type": "Unattended",
    //       "InputArguments": "{\"message\":\"Aloha\"}",
    //       "OutputArguments": null,
    //       "Id": 160856
    //     }
    //   ]
    // }

    // Sample code for parsing the JSON response...
    // Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    var Key *string = new(string)
    var StartTime *string = new(string)
    var EndTime *string = new(string)
    var State *string = new(string)
    var Source *string = new(string)
    var SourceType *string = new(string)
    var BatchExecutionKey *string = new(string)
    var Info *string = new(string)
    var CreationTime *string = new(string)
    var StartingScheduleId *string = new(string)
    var ReleaseName *string = new(string)
    var v_Type *string = new(string)
    var InputArguments *string = new(string)
    var OutputArguments *string = new(string)
    var Id int

    odata_context := jResp.StringOf("\"@odata.context\"")
    i := 0
    count_i := jResp.SizeOfArray("value")
    for i < count_i {
        jResp.SetI(i)
        Key = jResp.StringOf("value[i].Key")
        StartTime = jResp.StringOf("value[i].StartTime")
        EndTime = jResp.StringOf("value[i].EndTime")
        State = jResp.StringOf("value[i].State")
        Source = jResp.StringOf("value[i].Source")
        SourceType = jResp.StringOf("value[i].SourceType")
        BatchExecutionKey = jResp.StringOf("value[i].BatchExecutionKey")
        Info = jResp.StringOf("value[i].Info")
        CreationTime = jResp.StringOf("value[i].CreationTime")
        StartingScheduleId = jResp.StringOf("value[i].StartingScheduleId")
        ReleaseName = jResp.StringOf("value[i].ReleaseName")
        v_Type = jResp.StringOf("value[i].Type")
        InputArguments = jResp.StringOf("value[i].InputArguments")
        OutputArguments = jResp.StringOf("value[i].OutputArguments")
        Id = jResp.IntOf("value[i].Id")
        i = i + 1
    }


    http.DisposeHttp()
    json.DisposeJsonObject()
    sbResponseBody.DisposeStringBuilder()
    jResp.DisposeJsonObject()

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: application/json"
	-H "X-UIPATH-TenantName: {{tenantName}}"
	-H "X-UIPATH-OrganizationUnitId: {{folderId}}"
	-d '{ "startInfo":
   { "ReleaseKey": "5b754c63-5d1a-4c37-bb9b-74b69e4934bf",
     "Strategy": "Specific",
     "RobotIds": [ 1553 ],
     "NoOfRobots": 0,
     "Source": "Manual",
     "InputArguments": "{\"greeting\":\"Aloha\"}"
   } 
}'
https://domain.com/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs

Postman Collection Item JSON

{
  "name": "Jobs - Start job with inputs",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "application/json",
        "type": "text"
      },
      {
        "key": "X-UIPATH-TenantName",
        "value": "{{tenantName}}",
        "type": "text"
      },
      {
        "key": "X-UIPATH-OrganizationUnitId",
        "value": "{{folderId}}",
        "type": "text"
      }
    ],
    "body": {
      "mode": "raw",
      "raw": "{ \"startInfo\":\r\n   { \"ReleaseKey\": \"5b754c63-5d1a-4c37-bb9b-74b69e4934bf\",\r\n     \"Strategy\": \"Specific\",\r\n     \"RobotIds\": [ 1553 ],\r\n     \"NoOfRobots\": 0,\r\n     \"Source\": \"Manual\",\r\n     \"InputArguments\": \"{\\\"greeting\\\":\\\"Aloha\\\"}\"\r\n   } \r\n}"
    },
    "url": {
      "raw": "{{url}}/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs",
      "host": [
        "{{url}}"
      ],
      "path": [
        "odata",
        "Jobs",
        "UiPath.Server.Configuration.OData.StartJobs"
      ]
    },
    "description": "Starting in v2018.3, jobs can accept input parameters."
  },
  "response": [
    {
      "name": "Jobs - Start job with inputs",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{ \"startInfo\":\r\n   { \"ReleaseKey\": \"5b754c63-5d1a-4c37-bb9b-74b69e4934bf\",\r\n     \"Strategy\": \"Specific\",\r\n     \"RobotIds\": [ 1553 ],\r\n     \"NoOfRobots\": 0,\r\n     \"Source\": \"Manual\",\r\n     \"InputArguments\": \"{\\\"message\\\":\\\"Aloha\\\"}\"\r\n   } \r\n}"
        },
        "url": {
          "raw": "{{url}}/odata/Jobs/UiPath.Server.Configuration.OData.StartJobs",
          "host": [
            "{{url}}"
          ],
          "path": [
            "odata",
            "Jobs",
            "UiPath.Server.Configuration.OData.StartJobs"
          ]
        }
      },
      "status": "Created",
      "code": 201,
      "_postman_previewlanguage": "",
      "header": [
        {
          "key": "CF-RAY",
          "value": "43b31c105eefbf07-FRA",
          "name": "CF-RAY",
          "description": "",
          "type": "text"
        },
        {
          "key": "Cache-Control",
          "value": "no-store, must-revalidate, no-cache, max-age=0",
          "name": "Cache-Control",
          "description": "",
          "type": "text"
        },
        {
          "key": "Connection",
          "value": "keep-alive",
          "name": "Connection",
          "description": "",
          "type": "text"
        },
        {
          "key": "Content-Length",
          "value": "425",
          "name": "Content-Length",
          "description": "",
          "type": "text"
        },
        {
          "key": "Content-Type",
          "value": "application/json; odata.metadata=minimal",
          "name": "Content-Type",
          "description": "",
          "type": "text"
        },
        {
          "key": "Date",
          "value": "Mon, 16 Sep 2018 08:30:56 GMT",
          "name": "Date",
          "description": "",
          "type": "text"
        },
        {
          "key": "Expect-CT",
          "value": "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\"",
          "name": "Expect-CT",
          "description": "",
          "type": "text"
        },
        {
          "key": "OData-Version",
          "value": "4.0",
          "name": "OData-Version",
          "description": "",
          "type": "text"
        },
        {
          "key": "Server",
          "value": "cloudflare",
          "name": "Server",
          "description": "",
          "type": "text"
        },
        {
          "key": "Set-Cookie",
          "value": "; SameSite=lax",
          "name": "Set-Cookie",
          "description": "",
          "type": "text"
        },
        {
          "key": "Strict-Transport-Security",
          "value": "max-age=31536000; includeSubDomains",
          "name": "Strict-Transport-Security",
          "description": "",
          "type": "text"
        },
        {
          "key": "X-Content-Type-Options",
          "value": "nosniff",
          "name": "X-Content-Type-Options",
          "description": "",
          "type": "text"
        },
        {
          "key": "X-Frame-Options",
          "value": "DENY",
          "name": "X-Frame-Options",
          "description": "",
          "type": "text"
        },
        {
          "key": "api-supported-versions",
          "value": "5.0",
          "name": "api-supported-versions",
          "description": "",
          "type": "text"
        }
      ],
      "cookie": [
      ],
      "body": "{\n    \"@odata.context\": \"https://beta.uipath.com/odata/$metadata#Jobs\",\n    \"value\": [\n        {\n            \"Key\": \"b618cdfd-8714-4dbf-9a00-0586a8953c90\",\n            \"StartTime\": null,\n            \"EndTime\": null,\n            \"State\": \"Pending\",\n            \"Source\": \"Manual\",\n            \"SourceType\": \"Manual\",\n            \"BatchExecutionKey\": \"abbbb5de-d46a-4b9b-8f73-8a3247be0a0e\",\n            \"Info\": null,\n            \"CreationTime\": \"2018-09-21T13:28:31.1449691Z\",\n            \"StartingScheduleId\": null,\n            \"ReleaseName\": \"Heyyo_playground\",\n            \"Type\": \"Unattended\",\n            \"InputArguments\": \"{\\\"message\\\":\\\"Aloha\\\"}\",\n            \"OutputArguments\": null,\n            \"Id\": 160856\n        }\n    ]\n}"
    }
  ]
}