2
I’m making a requisition with the WebClient
and would like to know if it is possible to add a Header within the class instance WebClient
, example:
WebClient client = new WebClient(){
Encoding = System.Text.Encoding.UTF8,
Headers =new WebHeaderCollection().Add("APIKey",API.APIKey) //Recebo erro aqui pois o retorno de `Add()` é void
};
I know I could solve by just doing so:
WebClient client = new WebClient(){
Encoding = System.Text.Encoding.UTF8
};
client.Headers.Add("APIKey",API.APIKey);
But I wonder if it is possible to do what I was doing in the first code without receiving this error.