Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

POST from client is not working

$
0
0

Hi,

I'm trying to POST to my WebAPI server unsuccessfully. What is wrong with this code? I've tested this Web API using Postman am,d it's ok. Here is my code.

                // Send Fire Event to PMK
                HttpClient client = new HttpClient();
                client.BaseAddress = new Uri("http://192.168.151.100:8080/");
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(
                    new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

                var serialize = JsonConvert.SerializeObject(fireEvent);
                var response = await client.PostAsync("api/FireEvents", 
                    new StringContent(serialize, Encoding.Unicode, "application/json"));

Thank you soo much

Jannen


Viewing all articles
Browse latest Browse all 4850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>