01-23-2023 04:50 PM - edited 01-23-2023 05:06 PM
Hello,
The Cisco URL = https://developer.webex-cx.com/documentation/search/v1/search-tasks has an online API test utility. I was able to create a GraphQL query (See below) and get a reply with some data. At the end of the reply there is a "hasNextPage": true,".
My Question is how do I get the next page via this test online utility? Should I include somewhere in the GraphQL syntax command that specifies the 2nd cursor (i.e. pagination:{cursor:"2"} ) - If so where does the "command" go in the GraphQL query?
Example of my GraphQL
{
#Call Statistics by Agent
task(
# NOTE: from and to are mandatory arguments that take the Epoch timestamp in milliseconds
from: 1650000000000
to: 1659570373205
timeComparator: createdTime
filter: {
and: [
{ direction: { equals: "inbound" } }
{ channelType: { equals: telephony } }
{owner: {notequals : {id: null}}}
]
}
aggregations: [
{ field: "id", type: count, name: "Total Contacts Handled" }
{ field: "connectedDuration", type: average, name: "Average Talk Time" }
{ field: "holdDuration", type: max, name: "Maximum Hold Time" }
{
field: "totalDuration"
type: average
name: "Average Handle Time by Agent"
}
]
) {
tasks {
owner {
name
id
}
aggregation {
name
value
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
Thanks, - Jim
Solved! Go to Solution.
04-04-2023 05:14 PM
Hi Team,
The pagination examples have been updated on the samples repo.
Please see the samples under:
For example:
Thanks & Regards,
Arunabh.
01-24-2023 10:07 AM
To get the next page of data, you need to include the "endCursor" value from the previous response in the "after" argument of the pagination object in your GraphQL query. So the pagination object should look like this: "pagination: {after: endCursorValue}". You would include this object within the query, like this:
{ task( from: 1650000000000 to: 1659570373205 timeComparator: createdTime filter: { and: [ { direction: { equals: "inbound" } } { channelType: { equals: telephony } } {owner: {notequals : {id: null}}} ] } aggregations: [ { field: "id", type: count, name: "Total Contacts Handled" } { field: "connectedDuration", type: average, name: "Average Talk Time" } { field: "holdDuration", type: max, name: "Maximum Hold Time" } { field: "totalDuration" type: average name: "Average Handle Time by Agent" }
] pagination: {after: endCursorValue} ) { tasks { owner { name id } aggregation { name value } } pageInfo { hasNextPage endCursor } } }
Make sure to replace "endCursorValue" with the actual value from the previous response. Please note that this is a sample, you should adjust it to your specific needs and requirements.
Please rate this and mark as solution/answer, if this resolved your issue
All the best,
AK
01-24-2023 11:47 AM
Hi Khorram1998,
Thank you for your reply. Unfortunately, it is not working for me.
Here is my endCursor value after the first query runs = "endCursor": "owner.name=poc10 user3::owner.id=87436b06-1476-4cf0-b1b5-a86bb3c11a4a" --- so I tried put the value of pagination: {after: XXXXXXXXXX} as "owner.name=poc10 user3::owner.id=87436b06-1476-4cf0-b1b5-a86bb3c11a4a" and "87436b06-1476-4cf0-b1b5-a86bb3c11a4a"
Both failed with this error message:
{
"trackingId": "dal_search_3156679a-9c50-4895-becc-1db40b9815df",
"error": {
"key": 400,
"message": [
{
"description": "Validation error of type WrongType: argument 'pagination' with value 'ObjectValue{objectFields=[ObjectField{name='after', value=StringValue{value='owner.name=poc10 user3::owner.id=87436b06-1476-4cf0-b1b5-a86bb3c11a4a'}}]}' contains a field not in 'Pagination': 'after' @ 'task'\n"
Here is my first response complete return:
{
"data": {
"task": {
"tasks": [
{
"owner": {
"name": "poc10 user3",
"id": "87436b06-1476-4cf0-b1b5-a86bb3c11a4a"
},
"aggregation": [
{
"name": "Total Contacts Handled",
"value": 5
},
{
"name": "Average Talk Time",
"value": 154430
},
{
"name": "Maximum Hold Time",
"value": 6139
},
{
"name": "Average Handle Time by Agent",
"value": 174311.6
}
]
}
],
"pageInfo": {
"hasNextPage": true,
"endCursor": "owner.name=poc10 user3::owner.id=87436b06-1476-4cf0-b1b5-a86bb3c11a4a"
}
}
}
}
04-04-2023 05:14 PM
Hi Team,
The pagination examples have been updated on the samples repo.
Please see the samples under:
For example:
Thanks & Regards,
Arunabh.
01-23-2023 05:27 PM
Hi Jim
This goes as an argument in the top level task
task(args…){}
Ie
task(
from:
to:
pagination: …)
Here is the example - it is in the samples
https://github.com/CiscoDevNet/webex-contact-center-api-samples/blob/main/graphql-sample/advanced.graphql
Thanks & Regards
Arunabh
01-24-2023 12:04 PM
Hi Arunabh,
Thank you for your reply.
The below query works except when I use "pagination" parameter with the below error:
ERROR: "description": "Invalid pagination cursor value for task' request. Cursor value order should be same as group by fields for pagination support with aggregation\n"
Can you help me determine where the syntax error is?
EXAMPLE QUERY:
{
#TOTAL CALLS BY Queue and Average Handle Time by Queue
task(
from: 1650000000000 #This can be set to Date.now() - (days * 24 * 60 * 60 * 1000) for lookback in days
to: 1659570373205 #This can be set to Date.now() in millis
timeComparator: createdTime
filter: {
and: [
{ direction: { equals: "inbound" } }
{ channelType: { equals: telephony } }
]
}
aggregations: [
{ field: "id", type: count, name: "Total Contacts by Queue" }
{ field: "queueDuration", type: average, name: "Average Queue Time" }
{ field: "queueDuration", type: max, name: "Maximum Queue Time" }
{
field: "totalDuration"
type: average
name: "Average Handle Time by Queue"
}
] pagination: {cursor: "0"}
) {
tasks {
lastQueue {
name
id
}
aggregation {
name
value
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide