I have to check the result of an API for a test case: I have the following code:
public static string requestApiPost(String url, String parameter){ System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(); client.BaseAddress = new System.Uri(url); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(System.Text.ASCIIEncoding.UTF8.GetBytes(string.Format("0}:{1}", "login", "pass")))); HttpContent httpContent = new StringContent(parameter, Encoding.UTF8, "application/json"); httpContent.Headers.Add("content-length",parameter.Length.ToString()); HttpResponseMessage messge = client.PostAsync(url, httpContent).Result; string result = messge.Content.ReadAsStringAsync().Result; return result; }This code used to work, but it stops working after I changed of computer.
When I make this request on Postman, I have results, and the application I have to test also has results, but not Ranorex.
Request does not return error, I have 200 for StatusCode with "OK" in ReasonPhrase. But my function return "[ ]". I have the exact same function with a GET request, and this one still works! I tried everything I don't know what to do, please help !