Search code examples
c#tfsjson.netazure-devopstfs-sdk

JsonSerializationException from TFS REST API response


I am trying to use the new TFS/VSTS REST APIs with our on-prem TFS 2015 server, and cannot retrieve test runs as the response fails internal validation.

Using client code like the following:

var connection = new VssConnection(serverUri), credentials);
var client = connection.GetClient<TestManagementHttpClient>();
var runs = await client.GetTestRunsAsync("project", planId:183110);

throws a JsonSerializationException in line 3 with the following message:

Required property 'environmentName' not found in JSON. Pathvalue[0].testEnvironment', line 1, position 582.

which is accurate. Checking the response in Fiddler shows that the testEnvironment property only has an environmentId property, no name. I have uploaded a trimmed sample of the response to this gist.

My question is why does TFS not return this value or alternatively, is there a way to force the API SDK to ignore this validation error?


Solution

  • I can reproduce that issue if includeRunDetails parameter is true. I reported a bug here that you can vote it.

    The workaround is that you could set includeRunDetails to false to get test runs without details include, then base on the result (test run id) to get a test run with details that you want.

    client.GetTestRunByIdAsync