Skip to content

Instantly share code, notes, and snippets.

@eprugh
Created November 28, 2016 17:38
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 eprugh/7e028c85e94daefc5cdcc4b446eef893 to your computer and use it in GitHub Desktop.
Save eprugh/7e028c85e94daefc5cdcc4b446eef893 to your computer and use it in GitHub Desktop.
//Common testing requirement. If you are consuming an API in a sandbox/test region, uncomment this line of code ONLY for non production uses.
//System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
//Be sure to run "Install-Package Microsoft.Net.Http" from your nuget command line.
using System;
using System.Net.Http;
var baseAddress = new Uri("https://private-anon-6009d9f50c-pactsafe.apiary-mock.com/");
using (var httpClient = new HttpClient{ BaseAddress = baseAddress })
{
httpClient.DefaultRequestHeaders.TryAddWithoutValidation("authorization", "Bearer {access_token}");
using (var content = new StringContent("{ \"name\": \"New Request\", \"description\": \"This is an internal description of the request\", \"subject\": \"Subject line for email\", \"message\": \"Message to signers\", \"signing_order\": false, \"invite_only\": true}", System.Text.Encoding.Default, "application/json"))
{
using (var response = await httpClient.PostAsync("undefined", content))
{
string responseData = await response.Content.ReadAsStringAsync();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment