I recently learned how to make get HTTP requests with C#'s System.Net.Http library. I'm wondering how I'd go about making a post request using headers. Is there any simple way to do so? I haven't really tried much. But in python here's how I'd do it:
import requests
authorization_variable = "something here"
headers = { 'Authorization': authorization_variable, 'Content-Type': 'application/json','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36'};
r = requests.post("https://example.com/", headers=headers)
That's basically what I want to achieve but in C#
The post request I'm looking to do takes 3 headers:
authorization,
Content-Type,
User-Agent.
My current code:
static async Task httpfunc()
{
var client = new HttpClient();
var responseString = await client.GetStringAsync("https://pastebin.com/raw/sUJb5t2Q");
Console.WriteLine(Convert.ToString(responseString));
Console.ReadLine();
}