Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Last active June 29, 2016 14:20
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 bjoerntx/d87d4ff300267766dd39d9969d10ed5e to your computer and use it in GitHub Desktop.
Save bjoerntx/d87d4ff300267766dd39d9969d10ed5e to your computer and use it in GitHub Desktop.
using (HttpClient client = CreateHttpClient())
{
// set the endpoint
HttpResponseMessage response = client.GetAsync("api.rsc/Customer").Result;
// return an ActionSettings object, if sucessful
if (response.IsSuccessStatusCode)
{
string result = await response.Content.ReadAsStringAsync();
List<Customer> customers =
JObject.Parse(result)["value"].ToObject<List<Customer>>();
Report report = new Report()
{
Customers = customers
};
ReportingCloud rc = new ReportingCloud(
"username",
"password",
new Uri("https://api.reporting.cloud"));
MergeBody mergeBody = new MergeBody() {
MergeData = report
};
List<string> results = rc.MergeDocument(
mergeBody, "CloudDriver_Sample.tx");
File.WriteAllBytes("results.pdf", Convert.FromBase64String(results[0]));
}
else
{
// throw exception with the message from the endpoint
throw new ArgumentException(response.Content.ReadAsStringAsync().Result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment