Click here to Skip to main content
15,918,275 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
response.content.readasasync returns always null help please :))

What I have tried:

<pre> public class ResultData
        public string Name { get; set; }

        public List<Bank> RresultObject { get; set; }

        public string UUId { get; set; }

        public string FirstName { get; set; }

        public string LastName { get; set; }

        public string address { get; set; }
        public string tel { get; set; }

        public string Marital_status { get; set; }

        public string Occupation { get; set; }

        public string PayIN { get; set; }

<pre> static async Task CallWebAPIAsync()

                using (var client = new HttpClient())
                    client.BaseAddress = new Uri("http://localhost:35799/");
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                    //GET Method
                    HttpResponseMessage response = await client.GetAsync("bank");
                    if (response.IsSuccessStatusCode)
                        // here always null <-<-<-
                        ResultData department = await response.Content.ReadAsAsync<ResultData>();

            catch (Exception ex)
                throw ex;
Updated 1-May-18 21:10pm
Richard MacCutchan 1-May-18 4:08am    
Look at the server code running on port 35799, and see what it is trying to return.

1 solution

What is the response if you open this url [http://localhost:35799/bank]?
Share this answer
Member 12350895 2-May-18 3:23am    
[http://localhost:35799/bank] is my url in my RestService from Here i select all Banks From DB.Its work in RestService but in Request return always bull:(
Vikas Kmr Chaturvedi 2-May-18 4:57am    
Have you tried replacing response.Content.ReadAsAsync<resultdata>(); with response.Content.ReadAsAsync<object>();
Member 12350895 2-May-18 14:41pm    
thank you its work.Can i have you Email?:))
Vikas Kmr Chaturvedi 3-May-18 1:46am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900