Need to update Test case status at run time using C#.

Mayank A 20 Reputation points
2023-06-12T14:59:20.0766667+00:00

Issue is:- I am able to connect with BaseURL with credentials in NetworkCredentials.But Response getting 404 System.ObjectDisposedException : Cannot access a disposed object.

Below is set code used:-

using (HttpClientHandler handler = new HttpClientHandler()){            
    handler.Credentials = new NetworkCredential("xx", "xx", "xx");                
    using (HttpClient client = new HttpClient(handler)){                
		client.BaseAddress = new Uri(baseUrl);
		client.DefaultRequestHeaders.Accept.Clear();
		client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
		string payload = $"[{{\"id\": \"162789\", \"outcome\": \"Passed\", \"state\": \"Completed\"}}]";
		string requestUrl = baseUrl + "_testExecution/Index";
		HttpResponseMessage response = await client.PatchAsync(requestUrl, new StringContent(payload, Encoding.UTF8, "application/json"));


C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,213 questions
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 69,656 Reputation points
    2023-06-12T22:40:08.6566667+00:00

    as the error is the server you are calling, you will need to debug that code. showing us the calling code does not help. most likely the payload does not have valid values, but we have no idea what a valid payload is.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.