Skip to content

Instantly share code, notes, and snippets.

@xdumaine
Created March 31, 2014 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xdumaine/9900498 to your computer and use it in GitHub Desktop.
Save xdumaine/9900498 to your computer and use it in GitHub Desktop.
var baseAddress = new Uri(API_URL_BASE);
var cookieContainer = new CookieContainer();
using (var handler = new HttpClientHandler() { CookieContainer = cookieContainer })
using (var client = new HttpClient(handler) { BaseAddress = baseAddress })
{
// some defaults, add a header and cookie for authenticating with the API
client.DefaultRequestHeaders.Add("User-Agent", USER_AGENT);
client.DefaultRequestHeaders.Add("X-AvoSig", AvoSignature);
cookieContainer.Add(baseAddress, new Cookie(COOKIE_NAME, CookieValue));
// Post the content and return the result
var response = client.PostAsync(uri, content);
return response.Result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment