2

GetWorkItemsAsync fails when it retrieves 1800 workitems. Example:

int[] ids = (from WorkItem info in wlinks select info.Id).ToArray();
WorkItemTrackingHttpClient tfvcClient = _tfs.GetClient<WorkItemTrackingHttpClient>();
List<Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models.WorkItem> dworkitems = tfvcClient.GetWorkItemsAsync(ids).Result;

If I pass array of Ids with 90 elements it works fine.

Is there any limit that it can get only n number of elements, how can we overcome this problem?

Micho
  • 3,929
  • 13
  • 37
  • 40
Kumar
  • 399
  • 4
  • 16
  • Any clear description you can provide to 'fails'? Any error? – yakobom Dec 19 '17 at 08:16
  • Message: "One or more errors occurred." Source "mscorlib" StackTrace " at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)\r\n at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)\r\n at System.Threading.Tasks.Task`1.get_Result()\r\n at TestCaseExport.FrmMain.button1_Click(Object sender, EventArgs e) in C:\\Users\\angolla\\Source\\Repos\\Export work items to excel from TFS\\TestCaseExport\\FrmMain.cs:line 4040" – Kumar Dec 19 '17 at 15:56
  • Please let me know if you need any other info, appreciate your help – Kumar Dec 19 '17 at 15:56

1 Answers1

4

Yes, there is a limitation of the URL length, it will get this exception once the URL length has been exceeded.

So, as a workaround you can limit your calls to a allowed range at a time (e.g. 200 ids at a time). Then call several times for the query.

Unfortunately you’ve hit a limitation of the URL length. Once the URL length has been exceeded, the server just gets the truncated version, so odds are high that the truncated work item id is not valid.

I recommend limiting your calls to 200 ids at a time.

Source here : https://github.com/Microsoft/vsts-dotnet-samples/issues/49

Reference this thread for the limitation of the URL length: What is the maximum length of a URL in different browsers?

This similar thread for your reference: Is there any restriction for number of characters in TFS REST API?

Andy Li-MSFT
  • 28,712
  • 2
  • 33
  • 55