PowerBuilder / Orchestrator / Robot Service - Get Robot Mappings
Back to Collection Items
integer li_rc
oleobject loo_Http
integer li_Success
oleobject loo_QueryParams
oleobject loo_Resp
oleobject loo_SbResponseBody
oleobject loo_JarrResp
integer li_RespStatusCode
oleobject loo_Json
string ls_RobotKey
string ls_User
string ls_MachineName
integer li_MachineId
string ls_RobotName
integer li_RobotType
integer li_HasLicense
integer li_TenantId
integer li_OrganizationUnitId
string ls_ExecutionSettings
integer li_Id
integer i
integer li_Count_i
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
// Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_QueryParams = create oleobject
// Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0
li_rc = loo_QueryParams.ConnectToNewObject("Chilkat.JsonObject")
loo_QueryParams.UpdateString("licenseKey","86753095683")
loo_QueryParams.UpdateString("machineName","TESTLAPTOP")
loo_Http.SetRequestHeader("Content-Type","application/json")
// Adds the "Authorization: Bearer <access_token>" header.
loo_Http.AuthToken = "<access_token>"
loo_Http.SetRequestHeader("X-UIPATH-OrganizationUnitId","{{folderId}}")
loo_Http.SetRequestHeader("X-UIPATH-TenantName","{{tenantName}}")
loo_Resp = loo_Http.QuickRequestParams("GET","https://domain.com/api/RobotsService/GetRobotMappings",loo_QueryParams)
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_QueryParams
return
end if
loo_SbResponseBody = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder")
loo_Resp.GetBodySb(loo_SbResponseBody)
loo_JarrResp = create oleobject
// Use "Chilkat_9_5_0.JsonArray" for versions of Chilkat < 10.0.0
li_rc = loo_JarrResp.ConnectToNewObject("Chilkat.JsonArray")
loo_JarrResp.LoadSb(loo_SbResponseBody)
loo_JarrResp.EmitCompact = 0
Write-Debug "Response Body:"
Write-Debug loo_JarrResp.Emit()
li_RespStatusCode = loo_Resp.StatusCode
Write-Debug "Response Status Code = " + string(li_RespStatusCode)
if li_RespStatusCode >= 400 then
Write-Debug "Response Header:"
Write-Debug loo_Resp.Header
Write-Debug "Failed."
destroy loo_Resp
destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JarrResp
return
end if
destroy loo_Resp
// Sample JSON response:
// (Sample code for parsing the JSON response is shown below)
// [
// {
// "robotKey": "1234567-abcd-890p-a67b-6d5b987dj",
// "user": "dean",
// "machineName": "TESTLAPTOP",
// "machineId": 20000,
// "robotName": "joe",
// "robotType": 3,
// "hasLicense": false,
// "tenantId": 1234,
// "organizationUnitId": 5678,
// "executionSettings": null,
// "id": 33445
// }
// ]
// Sample code for parsing the JSON response...
// Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code
i = 0
li_Count_i = loo_JarrResp.Size
do while i < li_Count_i
loo_Json = loo_JarrResp.ObjectAt(i)
ls_RobotKey = loo_Json.StringOf("robotKey")
ls_User = loo_Json.StringOf("user")
ls_MachineName = loo_Json.StringOf("machineName")
li_MachineId = loo_Json.IntOf("machineId")
ls_RobotName = loo_Json.StringOf("robotName")
li_RobotType = loo_Json.IntOf("robotType")
li_HasLicense = loo_Json.BoolOf("hasLicense")
li_TenantId = loo_Json.IntOf("tenantId")
li_OrganizationUnitId = loo_Json.IntOf("organizationUnitId")
ls_ExecutionSettings = loo_Json.StringOf("executionSettings")
li_Id = loo_Json.IntOf("id")
destroy loo_Json
i = i + 1
loop
destroy loo_Http
destroy loo_QueryParams
destroy loo_SbResponseBody
destroy loo_JarrResp
Curl Command
curl -G -d "licenseKey=86753095683"
-d "machineName=TESTLAPTOP"
-H "Authorization: Bearer <access_token>"
-H "Content-Type: application/json"
-H "X-UIPATH-TenantName: {{tenantName}}"
-H "X-UIPATH-OrganizationUnitId: {{folderId}}"
https://domain.com/api/RobotsService/GetRobotMappings
Postman Collection Item JSON
{
"name": "Robot Service - Get Robot Mappings",
"request": {
"method": "GET",
"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"
}
],
"url": {
"raw": "{{url}}/api/RobotsService/GetRobotMappings?licenseKey=86753095683&machineName=TESTLAPTOP",
"host": [
"{{url}}"
],
"path": [
"api",
"RobotsService",
"GetRobotMappings"
],
"query": [
{
"key": "licenseKey",
"value": "86753095683"
},
{
"key": "machineName",
"value": "TESTLAPTOP"
}
]
}
},
"response": [
{
"name": "Robot Service - Get Robot Service Mappings",
"originalRequest": {
"method": "GET",
"header": [
{
"key": "Content-Type",
"value": "application/json"
}
],
"url": {
"raw": "{{url}}/api/RobotsService/GetRobotMappings?licenseKey=86753095683&machineName=TESTLAPTOP",
"host": [
"{{url}}"
],
"path": [
"api",
"RobotsService",
"GetRobotMappings"
],
"query": [
{
"key": "licenseKey",
"value": "86753095683"
},
{
"key": "machineName",
"value": "TESTLAPTOP"
}
]
}
},
"status": "OK",
"code": 200,
"_postman_previewlanguage": "json",
"header": [
{
"key": "Date",
"value": "Mon, 28 Jan 2019 23:05:37 GMT"
},
{
"key": "Content-Type",
"value": "application/json; charset=utf-8"
},
{
"key": "Content-Length",
"value": "122"
},
{
"key": "Connection",
"value": "keep-alive"
},
{
"key": "Cache-Control",
"value": "no-store, must-revalidate, no-cache, max-age=0"
},
{
"key": "Content-Encoding",
"value": "gzip"
},
{
"key": "Vary",
"value": "Accept-Encoding"
},
{
"key": "Set-Cookie",
"value": "; SameSite=lax"
},
{
"key": "api-supported-versions",
"value": "7.0"
},
{
"key": "Request-Context",
"value": "appId=cid-v1:d00ce63d-0891-41e4-a17c-25b2c5382e49"
},
{
"key": "Access-Control-Expose-Headers",
"value": "Request-Context"
},
{
"key": "X-Content-Type-Options",
"value": "nosniff"
},
{
"key": "X-Frame-Options",
"value": "DENY"
},
{
"key": "Strict-Transport-Security",
"value": "max-age=31536000; includeSubDomains"
},
{
"key": "Expect-CT",
"value": "max-age=604800, report-uri=\"https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct\""
},
{
"key": "Server",
"value": "cloudflare"
},
{
"key": "CF-RAY",
"value": "4a071ad5fc4a247a-IAD"
}
],
"cookie": [
],
"body": "[\n {\n \"robotKey\": \"1234567-abcd-890p-a67b-6d5b987dj\",\n \"user\": \"dean\",\n \"machineName\": \"TESTLAPTOP\",\n \"machineId\": 20000,\n \"robotName\": \"joe\",\n \"robotType\": 3,\n \"hasLicense\": false,\n \"tenantId\": 1234,\n \"organizationUnitId\": 5678,\n \"executionSettings\": null,\n \"id\": 33445\n }\n]"
}
]
}