I have a WebClient
like this:
WebClient _webClient = new WebClient
{
UseDefaultCredentials = true,
Encoding = System.Text.Encoding.UTF8,
I think you can also do it like this (without the :
in the header):
private static WebClient _doClient = new WebClient
{
BaseAddress = "https://api.digitalocean.com/v2/domains/example.com/",
Headers = new WebHeaderCollection { { "Authorization", "Bearer " + _digitalOceanApiKey } }
};
You can do it like this. You have to split the property and its value by a colon (:
):
WebClient _webClient = new WebClient
{
UseDefaultCredentials = true,
Encoding = System.Text.Encoding.UTF8,
Headers = new WebHeaderCollection
{
"user-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"
}
};