API that returns document - changing document extension

Certified Lead Developer

We have an integration object that calls an API that returns a document. So far we only needed PDF so we hardcoded the extension to .PDF. Now we can also receive a TXT file that contains JSON data in it. What is the best way for us to dynamically set the extension depending on the document that we receive? The integration team added the Content-Type to the HTTP headers but when I remove the .pdf, the document extension is set by Appian to .bin. (The txt file is getting set to .json) Any recommendations on how to best implement this?

  Discussion posts and replies are publicly visible

Parents
  • Hey there! The Content-Type header actually isn't used to infer the extension. We use the Content-Disposition header.

    You're correct that you should remove the extension from the Document Name and Extension field (for example, "My Document")

    Sending a Content-Disposition header with a value of inline; filename="resume.txt" would result in a document called MyDocument.txt

    Sending a Content-Disposition header with a value of inline; filename="resume.pdf" would result in a document called MyDocument.pdf

    Hope this helps!

Reply
  • Hey there! The Content-Type header actually isn't used to infer the extension. We use the Content-Disposition header.

    You're correct that you should remove the extension from the Document Name and Extension field (for example, "My Document")

    Sending a Content-Disposition header with a value of inline; filename="resume.txt" would result in a document called MyDocument.txt

    Sending a Content-Disposition header with a value of inline; filename="resume.pdf" would result in a document called MyDocument.pdf

    Hope this helps!

Children