Unable to view and download PDF in appsheet

Hello Community members,

I’m trying to view a workflow pdf in the app itself. I’ve gone through the communty posts and figured that there are 2 ways of doing it - one is to create a file name/file column in the table with open file action to it. Second is to create a column for url.
Despite trying both methods several times - im getting a 404 error for method #1 and bad request for method #2. Seeking help to rectify any errors that I might be committing. PFB the details.

Method 1: Followed the method prescribed in this community post

Created a file type column in the table -In the workflow that creates a pdf, setting the value of file column to : /data/PurchaseOrders/2nd_Apr_202100:50:51 @ 267583bf.pdf

data/PurchaseOrders - relative folder path of generated pdf doc.
2nd_Apr_202100:50:51 @ 267583bf - file name set in create doc task of workflow (used the expression suggested in the post and disabled timestamp)

Later, added an action (external action: to open a file) and set file to [file name]. However, i get a 404 error on clicking the action button

Method 2: Followed the method prescribed by Aleksi in this community post

Created a File URl type column in the table and used the below formula for setting the URl - CONCATENATE(“https://www.appsheet.com/template/gettablefileurl?appName=",“Omxxxxxxx-2559xxx-21-02-23-2”,"&tableName=","Purchase requisition”,"&fileName=",[File name]). [file name] - /data/PurchaseOrders/2nd_Apr_202100:50:51 @ 267583bf.pdf

also tried this formula for URL column -CONCATENATE(“https://www.appsheet.com/template/gettablefileurl?appName=",“Omxxxxxxx-2559xxx-21-02-23-2”,"&tableName=","Purchase requisition”,"&fileName=",encodeurl[File name])

For both URL formulas, I’m getting a “bad request” on clicking the URL in the app.

Would really appreciate if someone can point out the mistake. I have dedicated hours to rectify it myself but to no effect.

Thanks in advance!

CONCATENATE(“https://www.appsheet.com/template/gettablefileurl?appName=",ENCODEURL(“Omxxxxxxx-2559xxx-21-02-23-2”),"&tableName=",ENCODEURL("Purchase requisition”),"&fileName=",ENCODEURL([File name]))

See also:

Hi Steve,

Tried the url formula that you suggested…still getting a “bad request” error. Any inputs?

I got nothing else. :frowning:

The 404 error means the file cannot be found and is usually an issue with the pathing. If you look closely at the path in the error where it is trying to find the file and compare that to your column, App Default Path, and physical location of the file, you will likely find that there is some mismatch.

In the post you reference, I did try to spell out what I ended up with as an implementation but it’s probably hard to pick out amongst the rest of the discussion. I really should condense it and re-write it into the Tips and Tricks. If you wish to go that route, I can help.

As for the URL method, I have not used it for showing files in an app so can’t speak to it.

1 Like


I compared the path in my file name column with the actual physical path…it looks to be the same. 404 error doesn’t mention the path it’s searching for(neither the url suggests).

I see that you have done a neat implementation in the post message!..Would really appreciate if you could condense the solution into Tips and Tricks so that I (and future solution seekers) can follow it better. Thanks!

I see now. It use to be that the 404 error message would show a string where you could piece together the path. It no longer does that. I guess as part of the tightening of security around files.

Ok, I’ll show what I have in hopes it helps.

In the app…

I have a Files view which shows files like so:

The column with the file icon is where the path of the file comes from. That column is define generically like so - note-there is no path info specified:

The applications “App default path” is defined like this

In my datasheet, the file path was generated by the workflow and then stored like this:

The physical file location on Google Drive:

Putting it all together

Appsheet uses the “App default path” as the starting point. It will then build your path like so:

App default path + Column defined path info + Column data

For example, I could have moved the “Files” portion of the path from the data stored in the sheet and placed it into the column since that is where all of the Files are being stored, and AppSheet would have calculated the same path.

A couple final tidbits…

Once the file is found, AppSheet can still locate the file EVEN AFTER RENAMING PHYSICAL FILE PATH and FILENAME…AND EVAN AFTER CLEARING CACHE. I believe this is possible because Google is DocID based. I suspect AppSheet translates the path the DocID so that no matter where it physically lives on G-Drive it can still be found.

On the other hand, if after successfully finding the file, I then change the sheet path info, the file can no longer be found. Again, I suspect this is because the path does not match any previous known successful paths and AppSheet tries to resolve it from scratch. With no file found, an error is displayed.

1 Like


Thanks a ton, really appreciate it! It’s working now in the preview. However, when I’m using the app on my phone, it’s opening the doc and immediately switching back to the detailed view. Is it because my app is not deployed?

No, should not matter if its deployed or not. I tested preview yesterday in an un-deployed app and didn’t see that issue. Let me try again now.

Preview of a generated PDF seems to be working fine on my iPhone.

Okay, I tried again…it starts downloading (android phone) and when it opens it re routes to the detailed app view. I guess it’s an unexpected behaviour then or some issue with my device

Definitely unexpected. I would search the community to see if anything similar has been reported - recently or in the past.

1 Like

A client of mine has reported the same behavior when he is using the installed app on Android. However, when he uses the browser link for the app, it seems to work.

1 Like

Thanks, will check it out

1 Like

Okay got it, thanks for the input!

1 Like