Hey @Pogboom,
Yes, you can achieve this by creating a dynamic JSON string based on Excel data. Here’s a solution using UiPath that leverages string manipulation along with reading Excel data.
Step-by-Step Solution:
-
Read Excel Data:
- Use the Read Range activity to read your Excel sheet into a DataTable (let’s call it
dtData).
- Use the Read Range activity to read your Excel sheet into a DataTable (let’s call it
-
Loop Through Excel Data:
- Use a For Each Row in DataTable activity to iterate through each row of
dtData.
- Use a For Each Row in DataTable activity to iterate through each row of
-
Construct JSON String:
- Inside the loop, use an Assign activity to build a JSON string dynamically. For example:
jsonString = $"{{""priceList"":{{""id"":""{row("ID").ToString}"",""currency"":""{row("Currency").ToString}"",""name"":""{row("Name").ToString}"",""description"":""{row("Description").ToString}""}}}}"
- Inside the loop, use an Assign activity to build a JSON string dynamically. For example:
-
Send HTTP Request:
- Use the HTTP Request activity to send the constructed JSON as part of your request body.
Example JSON Output:
{
"priceList": {
"id": "1109",
"currency": "A",
"name": "B",
"description": "C"
}
}
Additional Tips:
- If the JSON structure is more complex, consider using the
Newtonsoft.Jsonpackage to serialize your DataTable rows into JSON objects. - You can also use Build Data Table activity for quick testing.
Please mark this as a solution if it helps! ![]()
Best,
Chaitanya