0

I'm trying out RestSharp with C# and I'm just trying to get a real simple request to work. I have the following super simple request to a public REST API. When I run this, I can put a break point right on the line where I set the response to the .GetAsync call. When I try to move on past this which is calling the .GetAysnc, nothing happens and my console app stops processing. It does not drop down into the Catch part of the Try...Catch so I'm not seeing any errors. Any suggestions on what I'm doing wrong?

try
{
    var testURL = "https://dog.ceo/api/breeds/list/all";
    var client = new RestClient(testURL);
    var request = new RestRequest();
    var response = await client.GetAsync(request);

}
catch (Exception ex)
{
    _log.LogError("Error getting Data. {0} | {1} | {2}", ex.Message, ex.StackTrace, ex.InnerException);
}
Caverman
  • 3,371
  • 9
  • 59
  • 115
  • The default timeout is 30 seconds so the code may just be waiting. Or you could be getting a lot of data. Try URL in a browser and see what results you get. You may get an error which will help solve issue. Or you may just be getting a lot of data. The GetAsync along with the await is looking for an end of file before continuing. The webpage may not be closing the connection which may be the root cause of the issue. – jdweng Aug 27 '22 at 08:19
  • Cannot reproduce with .NET 6 console app - RestSharp call returns roughly 200+ lines of JSON data, about 3K in payload, in 97ms ..... Not sure what's going in your code - I suspect it's not in this code here where the problem is.... – marc_s Aug 27 '22 at 09:41
  • I created a new simple project and added this code and it's still doing the same. I'm wondering if I need to set a proxy since I'm running through my work's network. Anyone know how to set that in v107+? I've really only found how to do it with v106 which is completely different. I'll keep trying to research to find out about the proxy but though maybe someone could point me to an post they might now of. I'm not finding anything in RestSharp's documentation. – Caverman Aug 27 '22 at 17:57
  • This one is weird to me. I downgraded my test app to use v106 and it works just fine. No proxy needed. – Caverman Aug 28 '22 at 18:21

0 Answers0