I have this code:
String json = "{\"name\":\"listFiles\"}";
// Wrap our JSON inside a StringContent which then can be used by the HttpClient class
HttpContent httpContent = new StringContent(json, Encoding.UTF8, "application/json");
HttpResponseMessage response = client.PostAsync(endPoint, httpContent).Result;
response.EnsureSuccessStatusCode();
when this post is done, I can see that server received a call but the content is blank (content size is correct, but it has no data).
I tried to investigate if the httpContent has the json data, but I can not see any data.
Why this code, post blank data to server and why I can not see any data inside httpContent?
How can I extract json back from httpContent, so I can check that it is properly initialized?
where is its content?
Edit1
I checked the server and I am getting this data:
POST /osc/command/execute HTTP/1.1
Content-Type: application/json
Accept: application/json, application/xml, text/json, text/x-json, text/javascript, text/xml
User-Agent: RestSharp/106.2.1.0
Host: 192.168.1.138
Content-Length: 32
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
when I am sending data using restshart library as follow:
var client = new RestClient("http://192.168.1.138/osc/command/execute");
var request = new RestRequest(Method.POST);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\n  \"name\":\"camera.listFiles\"\n}\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
when I post the same code using postman, I am getting this on server:
POST /osc/command/execute HTTP/1.1
cache-control: no-cache
Postman-Token: 83ecd3ec-a85d-41a6-ab0e-029ee1690cce
Content-Type: application/json
User-Agent: PostmanRuntime/6.3.2
Accept: */*
Host: 192.168.1.138
accept-encoding: gzip, deflate
content-length: 32
Connection: keep-alive
{
 "name":"camera.listFiles"
}
so why there is nothing at the end of packet that I am reading with content that I posted?
Edit 2
I posted the data to "http://httpbin.org/post" and the result that I am getting is:
{
 "args": {},
 "data": "{\"name\":\"listFiles\"}",
 "files": {},
 "form": {},
 "headers": {
   "Accept": "application/json",
   "Connection": "close",
   "Content-Length": "20",
   "Content-Type": "application/json; charset=utf-8",
   "Expect": "100-continue",
   "Host": "httpbin.org"
 },
 "json": {
   "name": "listFiles"
 },
 "origin": "91.240.174.154",
 "url": "http://httpbin.org/post"
}
I can not see any payload here, but I can see the json with my data in it. The question is that why there is no payload as explained in this document: How are parameters sent in an HTTP POST request?
note1
What I can see is that when I posted to "http://httpbin.org/post", the connection is closed, but when I posted to my server, the connection is keep-alive, what is the difference? Is there any possibility that I am not reading all data from client on server and I should wait for another packet?

 
    