API request return empy result only on Ranorex

Ranorex Studio, Spy, Recorder, and Driver.
pwo
Posts: 3
Joined: Wed Jan 16, 2019 2:42 pm

API request return empy result only on Ranorex

Post by pwo » Wed Jan 16, 2019 2:53 pm

Hi, I am using Ranorex 8.2.0.
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 !

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: API request return empy result only on Ranorex

Post by odklizec » Thu Jan 17, 2019 8:40 am

Hi,

Please try the same script with most recent Ranorex 8.3.2. Ranorex 8.2 is already obsolete and there is no point to debug something in an obsolete and no longer supported version ;) There were a lot of bug fixes done between 8.2 and 8.3.2.

Additionally, if the code worked before you've changed computer, then it indicates that there is something wrong with the computer? There may be either something missing or corrupted? Please examine Ranorex system requirements and check if your new computer matches them:
https://www.ranorex.com/help/latest/ran ... uirements/
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

pwo
Posts: 3
Joined: Wed Jan 16, 2019 2:42 pm

Re: API request return empy result only on Ranorex

Post by pwo » Thu Jan 17, 2019 10:58 am

Thanks for your help, I have trouble to update Ranorex, during the launch, Ranorex told me he has no internet connection, I tried with multiple connections (including 4g) and with firewall desactivated too, but Ranorex can't reach internet. Do I have another solution to update it?

Thank you again

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: API request return empy result only on Ranorex

Post by odklizec » Thu Jan 17, 2019 11:08 am

Hi,

I'm afraid, I've never experienced such issue. I would suggest to contact Ranorex support, via their support form available here:
https://www.ranorex.com/support-query/

Are you experiencing a problem while downloading the setup file or when the setup is already started?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

pwo
Posts: 3
Joined: Wed Jan 16, 2019 2:42 pm

Re: API request return empy result only on Ranorex

Post by pwo » Thu Jan 17, 2019 1:33 pm

I update Ranorex and it fix my problem!
Thank you very much for your help