Using REST API for Files Downloading not working

Hello there,

I’m trying to use the REST API for files downloading -

https://demo7.nutriscope.ca/rest/v2/files/0c513191-6692-b01f-069d-f707f1533b8b?access_token=a9f9ea04-f5e5-4ae0-97f7-8fedc2d08b3d

and i’m getting the following error:
{
“error”: “File not found”,
“details”: “File not found. Id: 0c513191-6692-b01f-069d-f707f1533b8b”
}

We are using CUBA 7.1.3.
We have a specific role for the API user and it has Use REST API set to true.

The other custom API endpoints (/services/…) work as expected. The files endpoint used to work before on CUBA 6.

I tried with a lot of FileDescriptors and nothing works. The file descriptors exists both in my db and amazon S3 bucket. The images are properly displayed in app, using the vaadin components.

I read the documentation but still no clue. I also searched for related keys in app.properties to set but nothing found.

Am I missing something?

Thanks,
-c

2 Likes

I managed to isolate the issue:

com.haulmont.addon.restapi.api.controllers.FileDownloadController:77

FileDescriptor fd = dataService.load(ctx);
returns null, even if the FileDescriptor exists in the database.

57%20AM

24%20AM

1 Like

Also, the query seems to return no FileDescriptor - through dataManager, this time.

image

image

1 Like

Mystery solved.

The problem was that I had no read permission on sys$FileDescriptor on the user’s role.

Maybe if the error was something like - “You’re not authorized to …” and not “File not found” it wouldn’t have taken hours to find out the problem…

Thank you for the feedback.
I’ve created an issue.