my team has been stumped on this one. We are using Business Intelligence REST service to get a PDF report from the server using jQuery GET ajax call . It returns the bytes of the PDF (looks like gibberish) but when I create a file in a SharePoint library from the bytes the PDF won't open, it says it is corrupt. If I write server c# code, I can convert the response from the REST query no problem into a PDF.
I've been able to successfully save uploaded PDFs and PDFs with a straight up *.pdf URL as well. There's something different with the format of the response.
Response is object Blob type=application/pdf
Response as XML looks like (base64?) JVBERi0xLjcKJeTjz9IKNCAwIG9iago8PC9MZW5ndGggMyAwIFIvRmlsdGVyL0ZsYXRlRGVjb2Rl... Raw response looks like pdf gibbeish (like if you open a PDF in notepad)
How can I save or open this as working PDF? Ultimately I need to upload it into SharePoint, but even just opening it in the browser as PDF would be great.
This code returns Blob
$.ajax(
{
url:"MYBUSINTELLIGENCESERVER/raylight/v1/documents/"+ docID +"/",
type: "GET",
dataType: "binary",
processData: false,
headers:
{
"Accept": "application/pdf",
"X-SAP-LogonToken":secToken
},
success: function(result)
{
uploadFile(result);
}
})
The uploadFile has about 20 variations that all fail. Code of no use. I imagine we're missing something basic, but can't figure it out.
Please help if you've ever successfully saved a business intelligence PDF with JavaScript!
This isn't a duplicate because none of the suggested duplicate answers worked. I found the answer on my own.