title: How to Add test results to a test run in VSTS using Rest API programatically
body: <p>I've got API link for this task</p>
  
  <pre><code>POST https://{instance}/DefaultCollection/{project}/_apis/test/runs/{run}/results?api-version={version}
  </code></pre>
  
  <p><strong><a href="https://www.visualstudio.com/en-us/docs/integrate/api/test/results#add-test-results-to-a-test-run" rel="nofollow noreferrer">https://www.visualstudio.com/en-us/docs/integrate/api/test/results#add-test-results-to-a-test-run</a></strong></p>
  
  <p>I need program to do through API way.</p>
  
  <p>Alternative, i've tried with program below</p>
  
  <pre><code>public void GetResult()
          {
              var u = new Uri("https://{UserAccount}.visualstudio.com");
              VssCredentials c = new VssCredentials(new Microsoft.VisualStudio.Services.Common.VssBasicCredential(string.Empty, "MyPAT"));
              var connection = new VssConnection(u, c);
              var testClient = connection.GetClient&lt;TestManagementHttpClient&gt;();
              int testpointid = 100;
              string teamProject = "Project12345";
              RunCreateModel run = new RunCreateModel(name: "APIRun7", plan: new Microsoft.TeamFoundation.TestManagement.WebApi.ShallowReference("100"), pointIds: new int[] { testpointid });
              TestRun testrun = testClient.CreateTestRunAsync(run, teamProject).Result;
              TestCaseResultUpdateModel testCaseUpdate = new TestCaseResultUpdateModel() { State = "Completed", Outcome = "Passed", TestResult = new Microsoft.TeamFoundation.TestManagement.WebApi.ShallowReference("100000") };
              //var testResults = testClient.UpdateTestResultsAsync(new TestCaseResultUpdateModel[] { testCaseUpdate }, teamProject, testrun.Id).Result;
              RunUpdateModel runmodel = new RunUpdateModel(state: "Completed");
              TestRun testRunResult = testClient.UpdateTestRunAsync(runmodel ,teamProject, testrun.Id, runmodel).Result;
          }​
  </code></pre>
  
  <p>I got the error:</p>
  
  <blockquote>
    <p>cannot convert from  'Microsoft.TeamFoundation.TestManagement.WebApi.TestCaseResultUpdateModel[]'
    to 'Microsoft.TeamFoundation.TestManagement.WebApi.TestCaseResult[]'</p>
  </blockquote>