Hello, When updating a file using the REST API (with either setDataField or setBinaryData), the user gets a warning when trying to download the file. Instead of opening it to a new window (like it usually does when updating the file manually in the UI), the browser says that the file may "damage the computer". Then the user has to confirm that he wants to save it to its computer, and then open it from there. I have tried updating a file using the SOAP API instead (setBinaryData), and it seems to work. (No warning and the file opens in a new window). The problem only occurs when using the REST API. Can you take a look at this? Thank you, Romain Pennes.
I'm not sure what you're doing: these API are used to send data to the server from custom HTTP client.
Yes, that is indeed what we are doing.
We have an external program (client) that checks a mailbox, and for each email it finds, it creates a record in our Rollbase app. If the email has an attachment, it saves it to an "upload file" field.
To do so, we are creating a record using REST method "create2" and then are updating it to attach the file using "setBinaryData".
Thank you for your help.
Do you see any errors when creating a record this way?
We don't get any errors.
We get the following messages:
After create:
24 fields have been processed.
Field "Votre CV" has been updated on N°2013-00415
So you have no REST-related issue.
Sorry,
I must not have been clear enough when trying to explain our problem.
The REST methods work fine when creating or updating a record.
We get a warning from the browser (Chrome, IE ...) on the UI, when trying to open the file by clicking on the file link (in views or view pages).
This warning is only being shown for the records that had been previously updated using the REST API.
Hope this helps.
Thank you again,
Kind regards,
I cannot help with this issue - this warning depends on your browser's settings.
Nevermind, sorry for the inconvenience.
The error was ours.
When using the setBinaryData method, we were using a wrong MIME type ("application/octet-stream"" instead of "application/pdf").
Everything works fine now.
Thank you again for your reactivity.
Could you please let me know as to how did you manage to upload a pdf/pptx using the setBinaryData API? I have been struggling to get that done but haven't had any luck so far.
Please make sure that setBinaryData call has valid contentType URL parameter.
This is the one I used for my pptx file: application/vnd.openxmlformats-officedocument.presentationml.presentation