Skip to main content
Added punctuation for readability. Fixed indentation to aid in readability of code. Highlighted inline code/class references.
Source Link
Jeremy Caney
  • 7.8k
  • 115
  • 58
  • 86

I only added Auththe authentication header to it and thisit worked for me AuthToken. AuthToken is either a string variable or the token itself I. I left out Thethe content type header and it just works, below. Below is the code Responsecode; Response is a string that has to be serialized to a JobjectJobject.

{ String Response = null; HttpClient client = new HttpClient(CertByPass()); client.Timeout = TimeSpan.FromMinutes(5); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(AuthToken); Response = await client.GetStringAsync(url); } 
{ String Response = null; HttpClient client = new HttpClient(CertByPass()); client.Timeout = TimeSpan.FromMinutes(5); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(AuthToken); Response = await client.GetStringAsync(url); } 

I only added Auth header to it and this worked for me AuthToken is either a string variable or the token itself I left out The content type header and it just works, below is the code Response is a string that has to be serialized to a Jobject

{ String Response = null; HttpClient client = new HttpClient(CertByPass()); client.Timeout = TimeSpan.FromMinutes(5); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(AuthToken); Response = await client.GetStringAsync(url); } 

I only added the authentication header to it and it worked for me. AuthToken is either a string variable or the token itself. I left out the content type header and it just works. Below is the code; Response is a string that has to be serialized to a Jobject.

{ String Response = null; HttpClient client = new HttpClient(CertByPass()); client.Timeout = TimeSpan.FromMinutes(5); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(AuthToken); Response = await client.GetStringAsync(url); } 
Source Link

I only added Auth header to it and this worked for me AuthToken is either a string variable or the token itself I left out The content type header and it just works, below is the code Response is a string that has to be serialized to a Jobject

{ String Response = null; HttpClient client = new HttpClient(CertByPass()); client.Timeout = TimeSpan.FromMinutes(5); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(AuthToken); Response = await client.GetStringAsync(url); }