-1

I have a database management class which has multiple methods to reach different endpoints on a REST API. Everything appears to be working except for this one issue. When the app is started, I am trying to reach an endpoint the exact same way I reach the other endpoints. For some reason, this one completely breaks the app and throws a NullReferenceException without any information.

I have confirmed that the client is not null, and the URL and endpoint works fine in Postman. I honestly have no idea what would be causing this exception, and the fact that it doesn't show any information about the exception just makes it worse.

private async void InitDatabase()
    {
        HttpResponseMessage response = await client.GetAsync("System?Guid=1");
        string responseString = await response.Content.ReadAsStringAsync();
        SysParams sysParams = JsonConvert.DeserializeObject<SysParams>(responseString);
    }

The error occurs when the first line is executed where client.GetAsync is called. Output Error Page Client Inspection

AcePilot10
  • 178
  • 1
  • 12
  • 2
    Possible duplicate of [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Sach Aug 25 '18 at 04:43
  • @Sach Thanks for the comment, but I know what a NullReferenceException is, I'm trying to figure out what's causing it in my situation. – AcePilot10 Aug 25 '18 at 04:55
  • 1
    The linked duplicate will guide how to figure out what's causing it in your situation – Sir Rufo Aug 25 '18 at 05:53
  • I'm still having trouble finding the error. I have surrounded the method with a try catch yet it doesn't catch it. The program still breaks without any stack trace. – AcePilot10 Aug 26 '18 at 07:46

1 Answers1

0

For some reason, it started working after I had made the call without awaiting it.

AcePilot10
  • 178
  • 1
  • 12