title: Downloading PDF from API using POST
body: <p>Im trying to POST a request with some header information and other parameters to my api and then have it return a PDF file.</p>
  
  <p>I've got the API communication working fine however I've tried several methods of viewing the PDF and none really work 100%. 
  The method below was found on stackoverflow and returns response data in PDF format however when it's converted to a blob to view it becomes blank.</p>
  
  <pre><code>[API]
  HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK);
  ReturnInformationITEM rtn = GetPDFData(); //Comes back as Base64
  response.Content = new ByteArrayContent(System.Convert.FromBase64String(rtn.Data));
  response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
  return response;
  
  
  [client]
  var blob=new Blob([result], {type: 'application/pdf'});
  var pom = document.getElementById("pdf" + $counter); 
  pom.setAttribute('href',window.URL.createObjectURL(blob));
  pom.setAttribute('download',"Test.pdf");
  pom.setAttribute('target','_blank');
  
  'I did have a click event here but firefox ignores it so I have to pass the href back to the pom and manully click it'
  </code></pre>
  
  <p>If I alter the API to return base64 and have the client decode it before becoming a blob it will diaply the page but with an ugly blob URL and when saving in safari it doesnt recognise the 'download' attribute.</p>
  
  <p>Does anyone know a method which can be used which will work cross browser and and allow for a filename to be prefilled? and if possible auto show the file upon returning the post data.</p>
  
  <p>Thanks</p>
  
  <p>Mark </p>