Hi. I am trying to upload a file using the REST API. This is what I am doing:
-
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.
-
Send a request to the REST API to upload a file including the user-token I got from login:
[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
- KO response:
[2015-06-28 18:17:37] app.ERROR: Exception UtilsBackendless:subirImagen Client error response [status code] 400 [reason phrase] Bad Request [url] 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