webapi download documents

Certified Senior Developer

Hello All,

Could you please help us to redirect the URL using Appian webapi.  Below is the sample code I used . Now the URL is displayed in the body because i mentioned in the body. I tried to mentioned in headers  but nothing happened. Also i didn't see any keywords apart from body,statuscode,headers in a!httpResponse. Requirement is to download the documents using URL .(documents URL's are dynamic so we are trying to use redirect here).

a!httpResponse(
status Code: 302,
body: {rule!example(fileName:concat(
"537",
"Customer "
"454",
".pdf"
))},
headers: {},
),

  Discussion posts and replies are publicly visible

Parents
  • Can you clarify - are you trying to download an Appian document or an external document? If you are downloading a document from Appian, I don't think you need a redirect. Instead, when you create a new web api, there is a template for creating a document download that you can use instead. If you do need the redirect, can you provide more information about your use case?

Reply
  • Can you clarify - are you trying to download an Appian document or an external document? If you are downloading a document from Appian, I don't think you need a redirect. Instead, when you create a new web api, there is a template for creating a document download that you can use instead. If you do need the redirect, can you provide more information about your use case?

Children
  • 0
    Certified Senior Developer
    in reply to Peter Lewis

    Thanks peter for look into this.. please find the details and let me know for any clarifications

    Use case : We are trying to display the aws s3 urls as links in appian(Pre signed urls). Currently we are using one of the s3 utility to generate the s3 pre signed URL but the url is expiring in 5secs. So we have to refresh the link every 5secs and in appian we can refresh only every 30 secs. Because of this challenge , to avoid this we are trying to redirect to s3 url upon user clicking the link.

    please refer the below link or below conversation for the little background on this

    https://community.appian.com/b/appmarket/posts/amazon-s3-utilities

    below is the question to mike who created the above plugin

    Hi Mike,

    Thanks for sharing this plugin.  We are using plug in to get the documents and display in appian. We are using links(S3URL) for users to download the documents. Looks like currently URL is expiring  in 5000 milliseconds. I think time is very short for the user to navigate to download. To overcome this sceanario we used a!refresh function but still the life of the url is short. We have around 10+ docs and URLs need to available for the user to download the pdf;s  Please let me know whether any option is increase the expTimeMillis to 5 mins or can we pass expTimeMillis as a parameter to the plugin.  Thanks in advance for your help. 

    below is the note from mike:

     I don't have documentation explaining this in detail, but in the plugin description there is a line "It can be used in a WebAPI object to redirect a user from Appian to a resource on S3". That is exactly what you need to do. As you experienced, you cannot generate an S3 link and directly put it on the form as it will expire inside 5s. What you need is a WebAPI that will take in a doc id, validate user access, generate the AWS link and respond with a 302 (redirect). You can then put static links to the web api on your form.

  • 0
    Appian Employee
    in reply to baratc

    Ok makes sense - did you try using a header called "Location"? Usually that's the best way to define a redirect URL: en.wikipedia.org/.../HTTP_302

  • +1
    Certified Senior Developer
    in reply to Peter Lewis

    Thanks Peter. We implemented the redirect and working as expected. Appreciate your help!

    Have a Great Day!!

  • 0
    Certified Lead Developer
    in reply to baratc

    Hi@baratc  :can u let me know the implementation with webapi