DataFlex / Orchestrator / Robot Service - Get Robot Mappings
Back to Collection Items
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
Boolean iSuccess
Variant vQueryParams
Handle hoQueryParams
Variant vResp
Handle hoResp
Variant vSbResponseBody
Handle hoSbResponseBody
Handle hoJarrResp
Integer iRespStatusCode
Variant vJson
Handle hoJson
String sRobotKey
String sUser
String sMachineName
Integer iMachineId
String sRobotName
Integer iRobotType
Boolean iHasLicense
Integer iTenantId
Integer iOrganizationUnitId
String sExecutionSettings
Integer iId
Integer i
Integer iCount_i
String sTemp1
Boolean bTemp1
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
Get Create (RefClass(cComChilkatJsonObject)) To hoQueryParams
If (Not(IsComObjectCreated(hoQueryParams))) Begin
Send CreateComObject of hoQueryParams
End
Get ComUpdateString Of hoQueryParams "licenseKey" "86753095683" To iSuccess
Get ComUpdateString Of hoQueryParams "machineName" "TESTLAPTOP" To iSuccess
Send ComSetRequestHeader To hoHttp "Content-Type" "application/json"
// Adds the "Authorization: Bearer <access_token>" header.
Set ComAuthToken Of hoHttp To "<access_token>"
Send ComSetRequestHeader To hoHttp "X-UIPATH-OrganizationUnitId" "{{folderId}}"
Send ComSetRequestHeader To hoHttp "X-UIPATH-TenantName" "{{tenantName}}"
Get pvComObject of hoQueryParams to vQueryParams
Get ComQuickRequestParams Of hoHttp "GET" "https://domain.com/api/RobotsService/GetRobotMappings" vQueryParams To vResp
If (IsComObject(vResp)) Begin
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
Set pvComObject Of hoResp To vResp
End
Get ComLastMethodSuccess Of hoHttp To bTemp1
If (bTemp1 = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
Send CreateComObject of hoSbResponseBody
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess
Get Create (RefClass(cComChilkatJsonArray)) To hoJarrResp
If (Not(IsComObjectCreated(hoJarrResp))) Begin
Send CreateComObject of hoJarrResp
End
Get pvComObject of hoSbResponseBody to vSbResponseBody
Get ComLoadSb Of hoJarrResp vSbResponseBody To iSuccess
Set ComEmitCompact Of hoJarrResp To False
Showln "Response Body:"
Get ComEmit Of hoJarrResp To sTemp1
Showln sTemp1
Get ComStatusCode Of hoResp To iRespStatusCode
Showln "Response Status Code = " iRespStatusCode
If (iRespStatusCode >= 400) Begin
Showln "Response Header:"
Get ComHeader Of hoResp To sTemp1
Showln sTemp1
Showln "Failed."
Send Destroy of hoResp
Procedure_Return
End
Send Destroy of hoResp
// 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
Move 0 To i
Get ComSize Of hoJarrResp To iCount_i
While (i < iCount_i)
Get ComObjectAt Of hoJarrResp i To vJson
If (IsComObject(vJson)) Begin
Get Create (RefClass(cComChilkatJsonObject)) To hoJson
Set pvComObject Of hoJson To vJson
End
Get ComStringOf Of hoJson "robotKey" To sRobotKey
Get ComStringOf Of hoJson "user" To sUser
Get ComStringOf Of hoJson "machineName" To sMachineName
Get ComIntOf Of hoJson "machineId" To iMachineId
Get ComStringOf Of hoJson "robotName" To sRobotName
Get ComIntOf Of hoJson "robotType" To iRobotType
Get ComBoolOf Of hoJson "hasLicense" To iHasLicense
Get ComIntOf Of hoJson "tenantId" To iTenantId
Get ComIntOf Of hoJson "organizationUnitId" To iOrganizationUnitId
Get ComStringOf Of hoJson "executionSettings" To sExecutionSettings
Get ComIntOf Of hoJson "id" To iId
Send Destroy of hoJson
Move (i + 1) To i
Loop
End_Procedure
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]"
}
]
}