I'm currently trying to send a GET request to a site called Monday
With .NET CORE the below code works and returns the Json content as expected, however when I use the same code with Framework 4.7.2 I get this error ProtocolViolationException: Cannot send a content-body with this verb-type.
My question is, why would this be working in .NET Core and not Framework 4.7.2 on a standard Console Application.
static void GetFoo()
{
Task task = Task.Run(async() =>
{
string url = "https://api.monday.com:443/v1/boards/foo/pulses.json?api_key=bar";
using (HttpClient httpClient = new HttpClient())
using (HttpRequestMessage httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, url))
{
httpRequestMessage.Headers.Add("Cach-Control",": max-age=0, private, must-revalidate");
httpRequestMessage.Content = new StringContent("", System.Text.Encoding.UTF8, "application/json");
HttpResponseMessage result = await httpClient.SendAsync(httpRequestMessage);
string data = await result.Content.ReadAsStringAsync();
// Just want to see a result for now, so writing it to the console.
Console.WriteLine(JsonConvert.DeserializeObject(data).ToString());
}
});
Task.WaitAll(task);
}