Skip to main content
Known Participant
May 13, 2021
Question

API that returns document - changing document extension

  • May 13, 2021
  • 3 replies
  • 0 views

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?

    3 replies

    colton.walker
    May 13, 2021

    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!

    Known Participant
    May 14, 2021

    [mention:8b24470e75c542bcaccd64f97aa3ceb6:e9ed411860ed4f2ba0265705b8793d05] thanks for the quick response. Can the integration team pass in any value for filename (ensuring that the file extension is correct)? And in the Integration object in Appian the file name would be overwritten with the value we enter in Document Name and Extension

    colton.walker
    May 14, 2021

    Yep, that's correct!