Sending asynchronous HTTP POST request with C# with Example



Sending asynchronous HTTP POST request with C# with Example

JSON body 
public static async Task PostAsync(this Uri uri, object value) 
{ 
 

var content = new ObjectContext(value.GetType(), value, new JsonMediaTypeFormatter()); 
using (var client = new HttpClient()) 
{ 
return await client.PostAsync(uri, content); 
} 
} 
. . . 
var uri = new Uri("http://stackoverflow.com/documentation/c%23/1971/performing-http-requests"); 
await uri.PostAsync(new { foo = 123.45, bar = "Richard Feynman" }); 
 

Parameter Details 
The path to the archive to open, specified as a relative or absolute path. A relative path is 
archiveFileName 
interpreted as relative to the current working directory. 

0 Comment's

Comment Form