Project 6 — Advanced

REST API + JSON + Database Bot

Modern automation sirf GUI pe nahi chalti — APIs se. Is project me bot banayenge jo CRM ki REST API se leads fetch kare, JSON parse kare, aur SQL Server me insert kare — token auth, rate limiting, retry ke saath. Ye "modern RPA developer" ka signature skill hai.

⏱ 30 min• Advanced• UiPath Studio (Community)

Project kya karega?

WHAT

Bot pehle OAuth token lega (login API call), phir leads ki paginated API call karega, har lead ka JSON parse karke DataTable banayega, aur SQL Server ke Leads table me upsert karega. Failed records Orchestrator queue me retry ke liye jayenge.

WHEN

System integration jab kare karni ho — CRM se ERP, ERP se warehouse, kisi bhi SaaS tool ka data warehouse me. API-first automation 2026 ki demand hai — sirf GUI bot banane wale replace ho rahe hain.

WHERE

Integration teams, data engineering ke chhote jobs, fintech operations (payment reconciliation APIs), HR tech (attendance API → payroll DB). Har SaaS company ke paas API hoti hai, usse chalne wale bots ki demand high hai.

Concept: REST API ek web service hai jise HTTP call (GET/POST/PUT) se bulaya jaata hai. JSON response aata hai — usme se fields nikalna parsing hai. UiPath me HTTP Request activity + Deserialize JSON Property / JSON Select Token — bas. Python nahi chahiye.

Step-by-step build

Main.xaml (Sequence)
 |
 +-- Try Catch
 |    +-- Sequence: Get Token
 |    |    +-- HTTP Request
 |    |         Url: https://api.crm.com/auth/token
 |    |         Method: POST
 |    |         Body: {"client_id": in_ClientId, "client_secret": in_Secret}
 |    |         ContentType: application/json
 |    |         ->  strTokenResp
 |    |    +-- Assign: strToken = Deserialize JSON Property(strTokenResp, "access_token")
 |    +-- Sequence: Fetch & Load
 |    |    +-- Assign  intPage = 1
 |    |    +-- While  blnMoreData
 |    |         +-- HTTP Request
 |    |         |      Url: "https://api.crm.com/leads?page=" + intPage + "&limit=100"
 |    |         |      Method: GET
 |    |         |      Headers: Authorization = "Bearer " + strToken
 |    |         |      ->  strLeadsResp
 |    |         +-- Assign: jArr = Deserialize JSON (strLeadsResp).SelectToken("data")
 |    |         +-- For Each  item in jArr
 |    |         |    +-- Assign: dtLeads.Rows.Add(item("id"), item("name"), item("email"), item("status"))
 |    |         +-- Assign: blnMoreData = strLeadsResp.Contains("next_page")
 |    |         +-- Assign: intPage = intPage + 1
 |    |         +-- Delay  1000 ms    (rate limit respect)
 |    |    +-- For Each Row in dtLeads
 |    |         +-- Try Catch
 |    |              +-- Execute Non Query (SQL):
 |    |              |      MERGE INTO Leads AS t
 |    |              |      USING (SELECT @id AS Id) AS s ON t.Id = s.Id
 |    |              |      WHEN MATCHED THEN UPDATE SET Name=@name, Status=@status
 |    |              |      WHEN NOT MATCHED THEN INSERT (Id, Name, Email, Status) VALUES (@id,@name,@email,@status);
 |    |              +-- Set Transaction Status / Write Row: "OK"
 |    |         +-- Catch
 |    |              +-- Add Queue Item  queue: "CRM_Lead_Failed"  Data: row
 |    +-- Catch (AuthException)
 |         +-- Log Message  LogLevel.Error  "Token expired - refresh flow run"
 |         +-- (Alert Orchestrator / terminate for retry)

JSON parsing ke 3 tarike

# 1. Deserialize JSON Property - simple flat field:
strToken = Deserialize JSON Property(strResp, "access_token")

# 2. JSON Select Token - nested path (JSONPath):
strCity = JsonSelectToken(strResp, "data[0].address.city")

# 3. For Each (JArray) - array iterate karke DataTable me:
jArr = Deserialize JSON(strResp).SelectToken("data")
For Each item in jArr -> dt.Rows.Add(item("id"), item("name"))

# XPath/JSONPath samjho to 90% API integration easy hai.

Error handling — auth, rate limit, duplicates

Enterprise tips

Interview question: "OAuth token expire ho jaye to kya karoge?" — Catch block me refresh token se naya access token HTTP call se generate karunga, phir failed API call retry. Token ko Orchestrator Asset me cache karunga, expiry timestamp track karunga. Aur "rate limit 429 aaye?" — Retry Scope with increasing delay, max 3 attempts, phir queue me park.

Exercise

Question: JSON response se ek simple field (jaise access_token) nikalne ki activity ka naam? (2-3 words)

Question: API failure pe retry logic wrap karne wali activity? (2 words)

Common mistakes

Lesson complete?

Project ban gaya? Ab next project pe chalte hain — HR Onboarding Multi-App Bot.

Popular courses: Data Science Course in Lucknow · AI Course in Lucknow · Python Course in Lucknow · Power BI Course · Data Analytics Course