Quantcast
Channel: Active questions tagged header - Stack Overflow
Viewing all articles
Browse latest Browse all 652

C# adding custom header to HttpClient post requests

$
0
0

I am trying to make a HttpClient POST request, and everything went well until the server requested that the header is

"Content-Type":"application/json"

but every request returns with an error.

After further investigation, the header is not being added.

I am adding the header using :

httpClient.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", @"application/json");

Is there any way to add the header or am I adding it the wrong way?


Viewing all articles
Browse latest Browse all 652

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>