Fetch value from JsonArray

Hi ,

I am trying to fetch conversation id from below json array .Please guide me to get that

{
“meta”: {
“pageSize”: 100,
“page”: 1
},
“links”: {
“self”: “/v1/routing/queues/62ed57/work-items?page=1&pageSize=100”,
“first”: “/v1/routing/queues/62ed57/work-items?page=1&pageSize=100”,
“prev”: null,
“next”: null
},
“data”: [
{
“id”: “61c385233418e6001bc892c0”,
“type”: “work_item”,
“attributes”: {
“resourceType”: “conversation”,
“status”: “assigned”,
“paused”: false,
“channel”: “chat”,
“firstEnterQueueAt”: “2021-12-22T20:05:55.261Z”,
“queuedCount”: 2,
“priority”: 1,
“itemSize”: 1,
“updatedAt”: “2022-09-12T15:21:46.806Z”,
“modifiedAt”: “2021-12-22T20:05:55.272Z”,
“createdAt”: “2021-12-22T20:05:55.261Z”,
“resourceRev”: 48,
“resourceCreatedAt”: “2021-12-22T19:58:42.471Z”,
“resourceDirection”: “in”,
“resourceFirstQueueTime”: 22792904245,
“rev”: 8,
“workItemNumber”: 1,
“lastRevision”: {
“enteredQueueAt”: “2022-09-12T15:20:26.716Z”,
“queueTime”: 80090,
“queueBusinessTime”: 80090,
“acceptedAt”: “2022-09-12T15:21:46.806Z”
}
},
“relationships”: {
“org”: {
“data”: {
“type”: “org”,
“id”: “5c3793b2693073001983a86a”
},
“links”: {
“self”: “/v1/orgs/5c3793b2693073001983a86a”
}
},
“resource”: {
“data”: {
“type”: “conversation”,
“id”: “61c383717f09df47”
}
},
“lastRevision”: {
“data”: {
“type”: “work_item_revision”,
“id”: “61c385233418e6001bc892c1”
}
},
“assignedTo”: {
“data”: {
“type”: “user”,
“id”: “6290eae365f5ba41”
},
“links”: {
“self”: “/v1/users/6290eae36560842209f5ba41”
}
},
“queue”: {
“data”: {
“type”: “queue”,
“id”: “62ed5a0e192408db5b506107”
},
“links”: {
“self”: “/v1/routing/queues/62ed5a0e192408db5b506107”
}
},
“acceptedBy”: {
“data”: {
“type”: “user”,
“id”: “6290eae36ba41”
},
“links”: {
“self”: “/v1/users/6290eae36560842209f5ba41”
}
}
},
“links”: {
“self”: “/v1/routing/work-items/61c385233418e6001bc892c0”
}
},
{
“id”: “6319e1560e446416bbc601a9”,
“type”: “work_item”,
“attributes”: {
“resourceType”: “conversation”,
“status”: “assigned”,
“paused”: false,
“channel”: “email”,
“firstEnterQueueAt”: “2022-09-08T12:34:31.303Z”,
“queuedCount”: 5,
“priority”: 1,
“itemSize”: 1,
“ivr”: {
“businessTime”: 0,
“time”: 0
},
“updatedAt”: “2022-09-12T15:09:46.178Z”,
“modifiedAt”: “2022-09-08T12:34:30.500Z”,
“createdAt”: “2022-09-08T12:34:30.493Z”,
“resourceRev”: 24,
“resourceCreatedAt”: “2022-09-08T12:34:28.681Z”,
“resourceDirection”: “in”,
“resourceFirstQueueTime”: 2622,
“rev”: 14,
“workItemNumber”: 1,
“lastRevision”: {
“enteredQueueAt”: “2022-09-12T15:07:46.685Z”,
“queueTime”: 90234,
“queueBusinessTime”: 90234,
“acceptedAt”: “2022-09-12T15:09:46.178Z”
}
},
“relationships”: {
“org”: {
“data”: {
“type”: “org”,
“id”: “5c3793b2693073001983a86a”
},
“links”: {
“self”: “/v1/orgs/5c3793b2693073001983a86a”
}
},
“resource”: {
“data”: {
“type”: “conversation”,
“id”: “6319e15404cac55ccd”
}
},
“lastRevision”: {
“data”: {
“type”: “work_item_revision”,
“id”: “6319e1560e4464d9f7c601aa”
}
},
“assignedTo”: {
“data”: {
“type”: “user”,
“id”: “6290eae9f5ba41”
},
“links”: {
“self”: “/v1/users/6290eae36560842209f5ba41”
}
},
“queue”: {
“data”: {
“type”: “queue”,
“id”: “62ed5a0e192408db5b506107”
},
“links”: {
“self”: “/v1/routing/queues/62ed5a0e192408db5b506107”
}
},
“acceptedBy”: {
“data”: {
“type”: “user”,
“id”: “6290eae36560842209f5ba41”
},
“links”: {
“self”: “/v1/users/6290eae36560842209f5ba41”
}
}
},
“links”: {
“self”: “/v1/routing/work-items/6319e1560e446416bbc601a9”
}
},
{
“id”: “631b55ac236704feaf317352”,
“type”: “work_item”,
“attributes”: {
“resourceType”: “conversation”,
“status”: “assigned”,
“paused”: false,
“channel”: “email”,
“firstEnterQueueAt”: “2022-09-09T15:03:08.293Z”,
“queuedCount”: 2,
“priority”: 1,
“itemSize”: 1,
“ivr”: {
“businessTime”: 0,
“time”: 0
},
“updatedAt”: “2022-09-09T15:17:14.901Z”,
“modifiedAt”: “2022-09-09T15:03:08.080Z”,
“createdAt”: “2022-09-09T15:03:08.072Z”,
“resourceRev”: 16,
“resourceCreatedAt”: “2022-09-09T15:03:06.434Z”,
“resourceDirection”: “in”,
“resourceFirstQueueTime”: 1859,
“rev”: 8,
“workItemNumber”: 1,
“lastRevision”: {
“enteredQueueAt”: “2022-09-09T15:10:49.746Z”,
“queueTime”: 311698,
“queueBusinessTime”: 311698,
“acceptedAt”: “2022-09-09T15:17:14.901Z”
}
},
“relationships”: {
“org”: {
“data”: {
“type”: “org”,
“id”: “5c3793b2601983a86a”
},
“links”: {
“self”: “/v1/orgs/5c3793b2693073001983a86a”
}
},
“resource”: {
“data”: {
“type”: “conversation”,
“id”: “631b55aa04cac62de”
}
},
“lastRevision”: {
“data”: {
“type”: “work_item_revision”,
“id”: “631b55ac236704dc6e317353”
}
},
“assignedTo”: {
“data”: {
“type”: “user”,
“id”: “6290eae36560842209f5ba41”
},
“links”: {
“self”: “/v1/users/6290eae36560842209f5ba41”
}
},
“queue”: {
“data”: {
“type”: “queue”,
“id”: “62ed5a0e192408db5b506107”
},
“links”: {
“self”: “/v1/routing/queues/62ed5a0e192408db5b506107”
}
},
“acceptedBy”: {
“data”: {
“type”: “user”,
“id”: “6290eae36560842209f5ba41”
},
“links”: {
“self”: “/v1/users/6290eae36560842209f5ba41”
}
}
},
“links”: {
“self”: “/v1/routing/work-items/631b55ac236704feaf317352”
}
}
]
}

Hello @tharani.natarajan ,

  1. Read text file
  2. Deserialize json object - outputVariable - VariableType(Newtonsoft.Json.Linq.Jobject)
  3. outputVariable(“data”)(“id”).ToString

Let us know if you face any challenge here.

Regards,
Rohith

Hi Rohith ,

I would require only the conversation id(i have marked those in bold )from the json output .

myJObject - output from deserialiaze JSON

Acces by Index / path to the first item id
grafik

Getting all IDs
grafik

Hi @tharani.natarajan

Check out the Documentation

Hope it will helps

Regards
Gokul

when tried this i get error as “Accessed Jarray values with invalid key value :(“id”).int 32 array index expected.”

kindly note the shared option from above

1 Like
1 Like

Hello @tharani.natarajan ,

Use index instead of “Id”.

Try this :
outputVariable(“data”)(0)(“relationships”)(“resources”)(“data”)(1).ToString

Thanks for this …if i have one than one conversation id …how to i fetch all of them … total count of conversation id will be dynamic

grafik

Let us know what is missing, when fetching dynamic all ids as done above

Kindly note:
Screenshots are done within the immediate panel also available at your end, which is the first stop tool for prototyping JSON retrievals

Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

Hi Peter ,as you could see there are 3 conversion Id in the Json output . Currently able to take only the 1st conversation id . I want all the conversation IDs that comes in json …

Yes, and as you can see in the again many often linked demo we do see 3 ids

1 Like

Thanks,it works

Hi ppr,

Can you please guide to fetch corresponding work-item id for the conversation id ?I tried using "Where "clause but unable to think a logic .

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.