Backendless Support
 
Solved

Unable to upload file via REST API with custom user role

Hi. I am trying to upload a file using the REST API. This is what I am doing:

1. Log in with a user that has a custom role called AdminUser and has permissions for everything, and I have restricted permissions to AuthenticatedUser and NonAuthenticatedUser roles so they can't upload files, only read them. I get the user-token without problems.

2. Send a request to the REST API to upload a file including the user-token I got from login:

  1. [2015-06-28 18:17:36] app.INFO: ClientErrorResponseExceptionUtilsBackendless:subirImagen, peticion: POST /v1/files/imagenes/marcas/dfafb9d436fa6ac44d9cd2f6e2cde59ad5d19fca.png HTTP/1.1 Host: api.backendless.com User-Agent: Guzzle/3.9.3 curl/7.28.1 PHP/5.6.2 Expect: 100-Continue application-id: XXXXXXXXXXX secret-key: XXXXXXXXXXX application-type: REST Content-Type: multipart/form-data user-token: XXXXXXXXXXX

3. KO response:

  1. [2015-06-28 18:17:37] app.ERROR: Exception UtilsBackendless:subirImagen Client error response [status code] 400 [reason phrase] Bad Request https://api.backendless.com/v1/files/imagenes/marcas/dfafb9d436fa6ac44d9cd2f6e2cde59ad5d19fca.png"> https://api.backendless.com/v1/files/imagenes/marcas/dfafb9d436fa6ac44d9cd2f6e2cde59ad5d19fca.png

If I change the security configuration to allow NonAuthenticatedUser to upload files, it works. I don't know if there is a problem with security roles for file uploads, or maybe I am sending something wrong in the request. Could you please help me with it?

Thanks!

Andrés

Leave a Comment

Comments (4)

photo
1

Hi Andrés,

It sounds like there is a problem with security roles for uploads. We will verify it and report our findings back to you.

Regards,

Mark

photo
1

Hi, Andrés. Thanks for you feedback.

This bug will be fixed in next update during a week or two.

photo
1

Hi Andres!

This issue already resolved.

Could you confirm?

Regards,

Kate.

photo
1

Hi all.

I have tried this again and now it is working. Thanks!