I have the following code to send an HTTP request, but it does not transmit any packets (checked using Wireshark).
var httpClient = new HttpClient();
string uri = "http://" + IP + ":" + port + "/";
var stringContent = new StringContent(xmlString, Encoding.UTF8, "application/xml");
var respone = httpClient.PutAsync(uri, stringContent);
However, it transmits packet when I add:
respone.Wait(100);
Can you please help on how do get httpClient.PutAsync to work without the wait?
Thanks!
As they already told you, you are using an asynchronous call so you have to wait until that action is solved to end your method/program.
Also, it's a good practice to use using statements for your httpClient and your content, so you free the memory once the code is executed. And maybe you'll want to react to the HTTP response. Try something like this: