The content type "application/pdf" doesn't make sense, as you're not
returning a PDF. (Not directly, that is.) You're returning a JSON
document. One of several fields in the JSON document is meant to
contain the PDF (that's what you told us) but it is still a JSON
document, and therefore the proper content type would be "application/json"
The type of "application/pdf" would be used if you were sending the PDF
directly without putting it inside a JSON document.
This, as well as the mention of content-disposition, makes me wonder if
perhaps you didn't mean to put the PDF inside JSON? Maybe you really
wanted to return the PDF directly? That would certainly be a lot more
commonplace of a task.
You mention that the PDF looks like "garbage", but it seems like that
would be expected in this case? After all a PDF document is a binary
document, it is not made up of human-readable text (at least, not
always). So you should expect binary data. Typically when putting
binary data inside a JSON (or similar) document, you'd want to base64
encode it (like Brad said) but, that's only going to be useful if the
receiving side expects it in that format.
Personally, that's where I would start... get a clear picture of what
you're expected to send. Reading this thread, I'm not at all sure.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.