Click here to Skip to main content
15,664,808 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi Friends,

I am sending values from windows application to net core web api.

I am not receiving values in the API.

Getting json deserialize error

Is there any alternative to send values to post api from windows applications?

What I have tried:

Windows application code :
WebClient client = new WebClient();

               client.BaseAddress = "";
               var url = "/api/Customers/add";
               client.Headers["Content-type"] = "application/json";
               string StoreName = ConfigurationManager.AppSettings["StoreName"];
               List<Customersinfo> bills = new List<Customersinfo>();

               foreach (DataRow dr in dt.Rows)

               Customersinfo Bill = new Customersinfo();
               Bill.Storename = StoreName;


               string data = JsonConvert.SerializeObject(bills);
               var response = client.UploadString(url, data);

               var result = JsonConvert.DeserializeObject<Customersinfo>(response);

.net API:
        public async Task<ObjectResult> AddCustomer([FromBody] List<Customersinfo> custinfo)
                if (custinfo.Count > 0)
					//Here I am not getting the data to insert into the database
Richard MacCutchan 10-Sep-22 7:05am    
Before you do anything else you should investigate why the error occurs. It may be something simple.
prasanna204 10-Sep-22 7:13am    
I worked on error and I wrote the same code

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