<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Web Api to download document using document id</title><link>https://community.appian.com/discussions/f/integrations/26315/web-api-to-download-document-using-document-id</link><description>Hi, 
 I have a scenario where i need to download document using web api. 
 All the document id&amp;#39;s stored in local db and uploaded documents are stored in document center. 
 Now i need a web api to download document that&amp;#39;s residing inside in appian. 
 The</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Web Api to download document using document id</title><link>https://community.appian.com/thread/134038?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2024 13:02:08 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:cbe6b8b0-b9b6-45ba-9828-d8b448981b14</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;Not sure what you mean, this is from the Appian example and the API expects a valid document ID in the URL.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Web Api to download document using document id</title><link>https://community.appian.com/thread/134031?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2024 12:40:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:60b8ce06-33a6-40c3-a149-a772cf31e5f3</guid><dc:creator>chiragj3013</dc:creator><description>&lt;p&gt;Hi &lt;a href="/members/stefanhelzle0001"&gt;Stefan Helzle&lt;/a&gt;&amp;nbsp;i have apply all this things but how we can pass document id or document path in the web api .&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Web Api to download document using document id</title><link>https://community.appian.com/thread/103286?ContentTypeID=1</link><pubDate>Fri, 21 Oct 2022 06:56:55 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9b4afbe9-adf8-45c0-8198-627255c85935</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;There is a ready made pattern available when you create a new Web API. The resulting code is this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;a!localVariables(
  local!pathArray: fn!cast(&amp;#39;type!{http://www.appian.com/ae/types/2009}Text?list&amp;#39;, http!request.pathSegments),
  local!document: tointeger(index(local!pathArray, 1, null)),
  /* We don&amp;#39;t want to serve arbitrary documents because it could be a security risk */
  local!extensionWhitelist: {&amp;quot;pdf&amp;quot;, &amp;quot;txt&amp;quot;, &amp;quot;png&amp;quot;, &amp;quot;jpg&amp;quot;, &amp;quot;jpeg&amp;quot;},
  if(
    /*
    * The path must be only 1 value, the document ID, and that ID must be a number.
    * Otherwise, we return a 404 Not Found
    */
    or(
      length(local!pathArray) &amp;lt;&amp;gt; 1,
      isnull(local!document),
      not(contains(local!extensionWhitelist, document(local!document, &amp;quot;extension&amp;quot;)))
    ),
    a!httpResponse(
      statusCode: 404,
      body: &amp;quot;404 Not Found&amp;quot;,
      headers: {}
    ),
    a!httpResponse(
      /*
      * If the query parameter &amp;quot;attachment&amp;quot; is set to true,
      * set an HTTP header that tells the client that the body of the response
      * should be downloaded. This overrides the default content-disposition
      * of &amp;quot;inline; filename=&amp;lt;filename&amp;gt;.&amp;lt;extension&amp;gt;&amp;quot;. We will automatically
      * set the content-type and length.
      */
      headers: if(
        http!request.queryParameters.attachment,
        a!httpHeader(
          name: &amp;quot;Content-Disposition&amp;quot;,
          value: concat(
            &amp;quot;attachment; filename=&amp;quot;&amp;quot;&amp;quot;,
            document(local!document, &amp;quot;name&amp;quot;),
            &amp;quot;.&amp;quot;,
            document(local!document, &amp;quot;extension&amp;quot;),
            &amp;quot;&amp;quot;&amp;quot;&amp;quot;
          )
        ),
        {}
      ),
      body: todocument(local!document)
    )
  )
)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>