I have a web service (web site) that returns a pdf as a binary file. You pass in an ID and get the contents of that particular pdf.
Say, for example: http://somesite.com/getPdf?id=12
This works fine.
I would like to call this from my .NET c# program.
I have tried the following, but I seem to be missing something:
private static async Task GetPdf()
{
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/pdf"));
client.DefaultRequestHeaders.Add("User-Agent", "someagent");
var taskResponse= client.GetAsync("http://somesite.com/getPdf?id=12");
var msg = await taskResponse;
}
Am I approaching this correctly? Any suggestions would be greatly appreciated.