1

I am accessing an external Api call which requires an authorization token my code looks like

HttpClient client = new HttpClient();
string baseUrl = "http://url/organizations/d5d6553e-6bb2-4081-87e2-353e80f47d6f/users.json";
client.BaseAddress = new Uri(baseUrl);

// Add an Accept header for JSON format.
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("Authorization", "Basic TFVBV0dkeFZlSklJZ0hjajM0M0I6");

HttpResponseMessage response = client.GetAsync(baseUrl).Result;

please let me know what to do

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
rajesh A
  • 373
  • 4
  • 10
  • Please provide more information! Whats requirements to clients for this api? How should resulting request should look like? – Maris Apr 08 '14 at 06:56
  • If it is WCF then you can simple ask for the `wsdl` and generate the client for this api. – Maris Apr 08 '14 at 06:58
  • you can check out this post - http://stackoverflow.com/questions/14627399/setting-authorization-header-of-httpclient . This may help . – Rabi Apr 08 '14 at 07:21
  • Hi, this is some external api,I am not sure its WCF,what I need to access the data throught the API call with authentication token.I added the token(which is base 64 encoding) to header as given above.Is it the correct way to add ? – rajesh A Apr 08 '14 at 07:41

0 Answers0