locked
HttpResponseMessage error RRS feed

  • Question

  • User448619955 posted

    hey there.

    I want to use web api in my app, when iI run my application I get an Internal Error message.

    using (var client = new HttpClient())
                {
                    client.BaseAddress = new Uri("http://x.x.x.x:90");
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
    
                    //GET Method
                    HttpResponseMessage response = await client.GetAsync("/api/Get_Customer?username=edf&password=erw&idno=12345");
    
    //status code 500,response gets an internal server error message

    Wednesday, October 30, 2019 9:24 AM

All replies

  • User753101303 posted

    Hi,

    http 500 is a server side error. Try maybe to inspect the payload to look for a hint else you'll have to guess (a wrong idno maybe or to get in touch with the 3rd party - or if you look at the other app, by default it should go to the Windows log).

    Wednesday, October 30, 2019 9:29 AM
  • User61956409 posted

    Hi vahid.ch,

    If possible, you can try to access this API endpoint from browser, and check if you can find more/detailed error message, which would help troubleshoot the issue.

    And you can also try to check if there are any useful information in response content, like below.

    using (var client = new HttpClient())
    {
        client.BaseAddress = new Uri("http://x.x.x.x:90");
    
        //code logic
    
        //GET Method
        HttpResponseMessage response = await client.GetAsync("/api/Get_Customer?username=edf&password=erw&idno=12345");
        Stream stream = await response.Content.ReadAsStreamAsync();
        StreamReader reader = new StreamReader(stream);
        string rc = reader.ReadToEnd();
    }

    Besides, you can check logging file to get error logs if you can access the hosting server.

    With Regards,

    Fei Han

    Thursday, October 31, 2019 1:44 AM