Last active
June 29, 2016 14:20
-
-
Save bjoerntx/d87d4ff300267766dd39d9969d10ed5e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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