setDataField & setBinaryData REST methods provoke a warn

Posted by Rollbase User on 12-Feb-2013 08:57

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.

All Replies

Posted by Admin on 12-Feb-2013 09:57
I'm not sure what you're doing: these API are used to send data to the server from custom HTTP client.
Posted by Admin on 12-Feb-2013 10:04
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.
Posted by Admin on 12-Feb-2013 11:16
Do you see any errors when creating a record this way?
Posted by Admin on 12-Feb-2013 11:41
We don't get any errors.

We get the following messages:

After create:

24 fields have been processed.

After update:

Field "Votre CV" has been updated on N°2013-00415

Posted by Admin on 12-Feb-2013 11:54
So you have no REST-related issue.
Posted by Admin on 12-Feb-2013 12:01

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,
Posted by Admin on 12-Feb-2013 15:41
I cannot help with this issue - this warning depends on your browser's settings.
Posted by Admin on 13-Feb-2013 05:14
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.
Posted by IramK on 03-Nov-2014 10:32

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.

Posted by pvorobie on 03-Nov-2014 11:19

Please make sure that setBinaryData call has valid contentType URL parameter.

Posted by IramK on 03-Nov-2014 11:21

This is the one I used for my pptx file: application/vnd.openxmlformats-officedocument.presentationml.presentation

This thread is closed