File Upload Failed via Rest API

Hi,

i’m trying to upload a file through REST API but I am getting an exception AccessDeniedException.

The following is the error:

I have already set the Upload files using REST API role permission.

I am not sure what other settings that I am missing to allow file upload from REST API.

Can anyone guide on this ?

Thank you.

Regards,
John

Hello,
your screenshoot says that it can not create a file. Most likely due to not having a permission - you gave permission to the REST API addon, but not to the user.
There are CUBA level permissions that I would recommend you try to set, and I believe it will most likely solve your problem, check this out:

If that doesn’t work, I would try to see if its OS level file permission problem, that is can your CUBA app write to the filesystem at all - it should, but maybe you changed the location of the file storage?
Maybe make a short experiment without REST API to see if its working File Storage - CUBA Platform. Developer’s Manual

If that doesn’t work, maybe you need to authenticate your service
https://doc.cuba-platform.com/manual-7.2/system_authentication.html
Basically it says if no user is logged in, so there is no current user, but system needs to do something on its own, possibly as result of schedulet action , you need enclose the code with authentication.begin(); and authentication.end(); - I think however this is not the case here, error message would be different.

1 Like

Hi,

This line in the log:

instructs that the user who is trying to upload the file lacks “CREATE” permission for the sys$FileDescriptor entity.

I was not able to find the sys$FileDescriptor through the roles screen

So i had to create a predefined Role through design time

You need to tick “System level” above the entities table.