@Yash Tiwari
If you're unable to receive a continuationToken, it means the API is failing at the very first step because the initial query is still trying to pull the full list and it's hitting the 20,000 work item limit before it can even start processing the request. This is a known behavior with certain Azure DevOps APIs when the total number of items in a collection is extremely large.
The reason it works now is that by manually reducing the number of test plans to under 20,000, you've removed the condition that triggers the size limit error. The API no longer has to handle an initial query that exceeds the limit, so it can return the results without an issue.
The "UI issue" you mentioned, where it says only 19,999 items will be fetched, is a direct reflection of this same size limit. It's Azure DevOps' way of telling you that it can't display all the data because of the query cap.
What to do moving forward
Since the API isn't providing a continuation token, your options are limited to filtering the data to reduce the result set of the initial query. You can't rely on pagination if the first call fails. Here are a few ways to filter your request to stay under the 20,000 limit, especially if you expect the number of test plans to grow again:
- Filter by Project: If you have multiple projects, query them one by one. The URL you're using already includes {{project}}, which is good. If your project has more than 20,000 test plans, you may need to apply further filtering.
- Filter by Date Range: Retrieve test plans created or modified within a specific time frame. This is often the most effective way to manage large datasets.
Example: You can use a query with a where clause to only get items from the last year or a specific month.
- Filter by State: If you only need a subset of the data, query for test plans in a specific state, such as 'Active' or 'In Progress'.
Example of a filtered query:
You would have to switch to the Work Item Query Language (WIQL) API to apply these filters, as the Test Plan API doesn't support them directly.
POST https://dev.azure.com/{organization}/{project}/_apis/wit/wiql?api-version=6.0
Content-Type: application/json
{
"query": "Select [System.Id] From WorkItems Where [System.WorkItemType] = 'Test Plan' and [System.CreatedDate] >= '2025-01-01T00:00:00.00Z' Order By [System.Id]"
}
After you get the IDs from this WIQL query, you can then use them to retrieve the full Test Plan details. This two-step process is a common workaround for this type of issue.