<?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>Document to Base64 expose as web-api</title><link>https://community.appian.com/discussions/f/integrations/20496/document-to-base64-expose-as-web-api</link><description>I have requirement where the web-api needs to be exposed which convert the appian document into base64 based on local id of document received in the request. 
 Appian version :20.4(on premise)</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Document to Base64 expose as web-api</title><link>https://community.appian.com/thread/80117?ContentTypeID=1</link><pubDate>Mon, 08 Mar 2021 07:22:54 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:5dadd995-bdfa-4200-8230-7cc5ba8dc423</guid><dc:creator>Ahmad Al-Buthom</dc:creator><description>[quote userid="47790" url="~/discussions/f/integrations/20496/document-to-base64-expose-as-web-api"]document into base64[/quote]
&lt;p&gt;you asked to retrieve a document in base64, that is how appian sends documents by default&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Document to Base64 expose as web-api</title><link>https://community.appian.com/thread/80116?ContentTypeID=1</link><pubDate>Mon, 08 Mar 2021 07:20:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:fad0c0a3-1b58-451d-9b68-2773b0df0062</guid><dc:creator>aravind.s</dc:creator><description>&lt;p&gt;&lt;span&gt;Ahmad,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I hope this retrieve&amp;nbsp;the document in Binary format not in base 64...&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Document to Base64 expose as web-api</title><link>https://community.appian.com/thread/80111?ContentTypeID=1</link><pubDate>Mon, 08 Mar 2021 06:52:08 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:9c57872b-f42a-4d5b-a459-69c50d49001e</guid><dc:creator>Ahmad Al-Buthom</dc:creator><description>&lt;p&gt;you mean like so?&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>