API Integration in RPA
RPA bots primarily interact with the user interface — but not every system interaction has to go through the screen. When a target system offers an API (Application Programming Interface), connecting to it directly is faster, more reliable, and less prone to breaking when the UI changes. Many enterprise bots combine UI automation for legacy systems with API calls for modern systems.
What Is a REST API?
A REST API is a way for two software systems to exchange data over the internet using standard HTTP commands. When your bot makes an API call, it sends a request to a server and receives a response — typically in JSON format — without needing to open any application on screen.
Analogy: API as a Restaurant Waiter
YOU (Bot) WAITER (API) KITCHEN (System)
─────────────────────────────────────────────────────────
"I need the → Request sent to → System looks up
balance for the API endpoint the data
account #1234"
← Response returned ← Data packaged
in JSON format as JSON response
Bot reads the JSON and uses the balance value
HTTP Methods in REST APIs
| Method | Purpose | RPA Example |
|---|---|---|
| GET | Retrieve data | Get customer details by account number |
| POST | Create new data | Create a new customer record |
| PUT | Update existing data | Update customer email address |
| PATCH | Partially update data | Change only the account status field |
| DELETE | Remove data | Delete a cancelled order record |
Making API Calls in UiPath
UiPath provides the HTTP Request activity for making API calls. You configure the URL, method, headers, and body — then the activity returns the response as a string.
Example: GET Request – Retrieve Customer Data
HTTP Request Activity:
├── URL: "https://api.crm.company.com/customers/" + accountNo
├── Method: GET
├── Headers:
│ Content-Type: application/json
│ Authorization: "Bearer " + apiToken
├── Output: responseBody (String variable)
└── Output: statusCode (Integer variable)
Response (responseBody):
{
"accountNo": "ACC-1234",
"name": "John Smith",
"email": "john.smith@email.com",
"balance": 15750.00,
"status": "Active"
}
Example: POST Request – Create a New Order
HTTP Request Activity:
├── URL: "https://api.erp.company.com/orders"
├── Method: POST
├── Headers:
│ Content-Type: application/json
│ Authorization: "Bearer " + apiToken
├── Body (JSON):
│ {
│ "customerId": customerID,
│ "productCode": productCode,
│ "quantity": quantity,
│ "deliveryDate": deliveryDate
│ }
├── Output: responseBody
└── Output: statusCode
Expected Response: statusCode = 201 (Created)
responseBody: { "orderId": "ORD-789", "status": "Confirmed" }
Parsing JSON Responses
API responses come back as JSON strings. The bot must parse the JSON to extract specific field values. In UiPath, you use the Deserialize JSON activity to convert the JSON string into a JObject that you can query by field name.
Deserialize JSON:
Input: responseBody (String)
Output: jsonData (JObject)
Then extract specific fields:
customerName = jsonData("name").ToString()
balance = CDbl(jsonData("balance"))
status = jsonData("status").ToString()
Result:
customerName = "John Smith"
balance = 15750.00
status = "Active"
Handling API Authentication
Most APIs require authentication to prevent unauthorised access. Common authentication methods:
API Key
A unique key sent in the request header. Simple to use.
Header: X-API-Key: your-api-key-here
Bearer Token (OAuth 2.0)
The bot first calls an authentication endpoint to receive a temporary access token, then uses that token in all subsequent API calls.
STEP 1: Get Token
POST https://auth.company.com/token
Body: { "client_id": clientID, "client_secret": clientSecret }
Response: { "access_token": "eyJhbGci...", "expires_in": 3600 }
STEP 2: Use Token in API Calls
Header: Authorization: Bearer eyJhbGci...
Basic Authentication
Username and password encoded in Base64 and sent in the header.
Header: Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Status Code Handling
Every API response includes a status code that tells you whether the request succeeded or failed. Your bot must check the status code and handle different outcomes.
| Status Code | Meaning | Bot Action |
|---|---|---|
| 200 OK | Request succeeded, data returned | Parse response and continue |
| 201 Created | New resource created successfully | Read new resource ID from response |
| 400 Bad Request | The bot sent invalid data | Log error, fix data, retry or skip |
| 401 Unauthorised | Authentication failed | Refresh token and retry |
| 404 Not Found | Resource does not exist | Handle as exception, log and continue |
| 429 Too Many Requests | Bot is being rate-limited | Wait and retry with exponential back-off |
| 500 Server Error | System-side failure | Retry after delay; alert if persistent |
Real-World Integration Pattern
USE CASE: Hybrid Bot — UI for legacy SAP + API for modern CRM
STEP 1: Read invoice data from email (UI – Outlook)
│
▼
STEP 2: Call CRM API (GET) to retrieve customer credit limit
URL: /customers/{customerId}/creditLimit
Response: { "creditLimit": 50000 }
│
▼
STEP 3: IF invoice amount < credit limit:
Enter invoice in SAP via UI (UI automation)
ELSE:
Call Approval API (POST) to create approval request
│
▼
STEP 4: Call CRM API (PATCH) to update invoice status
URL: /customers/{customerId}/invoices/{invoiceId}
Body: { "status": "Posted", "sapDocNo": sapDocNumber }
│
▼
STEP 5: Send confirmation email (UI – Outlook)
Summary
API integration allows RPA bots to interact with modern systems directly and reliably without going through the user interface. REST APIs use HTTP methods (GET, POST, PUT, DELETE) to retrieve and modify data. UiPath's HTTP Request activity handles API calls. JSON responses are parsed using Deserialize JSON. Authentication is managed through API keys, bearer tokens, or basic auth — all stored securely in Orchestrator Assets. Status code handling ensures the bot responds correctly to both success and error responses. Combining UI automation with API calls produces the most robust and efficient enterprise bots.
