How to set the value of a File/Image Upload File

Posted by stephen.vanrooyen on 01-Feb-2017 03:04

Hi Guys,
 
I have a similar problem as listed in the post below
https://community.progress.com/community_groups/rollbase/f/25/t/26534
 
I need to create records in a different Rollbase tenant, for this I’m using the REST method
https://www.rollbase.com/rest/api/createRecord
 
I need to create an image file as well as an upload file, is there a way to achieve this?
 
Regards,
http://www.aigs.co.za/templates/email_signatures/2016/stephen_van_rooyen.png
 

Posted by stephen.vanrooyen on 07-Feb-2017 04:30

Hi,
 
I managed to get this working, but I had to resort to using the SOAP methods instead.
The setBinaryData() method seemed to have done the trick.
 
There seems to be a limitation on the HttpPost Trigger as it does not allow Tokens in the URL.
This meant I could not pass the sessionId to subsequent methods after login in.
Vote here for the implementation of including tokens in the url of Http Post trigger.
 
Thanks again,
 
Regards,
http://www.aigs.co.za/templates/email_signatures/2016/stephen_van_rooyen.png
 

All Replies

Posted by mpiscoso@gmail.com on 03-Feb-2017 03:50

After you create the record using the REST api createRecord() you should be able to get the record's ID. At this point you would need to make another REST call using either the setBinaryData() [http://documentation.progress.com/output/rb/doc/index.html#page/rb%2Fsetbinarydata.html%23] or setDataField() [http://documentation.progress.com/output/rb/doc/index.html#page/rb%2Fsetdatafield.html%23] methods.

Both methods would require the file's Base-64 encoded binary value of file, the record's id, content type, and file name at least.

I would suggest using the POST method rather than GET for file uploads as you might run into the maxHTTPParameter limit.

Hope this helps.

Posted by stephen.vanrooyen on 03-Feb-2017 06:12

Hi,
 
Thanx for the feedback.
 
I’ve been playing around with the REST methods, and for some reason I’m running into some problems.
 
I’m using the REST method called create, to create a record in another Rollbase tenant.
When I include the values as URL parameters it works fine,
But as soon as I try sending the values as XML I keep getting  the below Error. (Even though my XML seems correct)
Error in thread catalina-exec-595 at 02/03/2017 11:10 AM: Error: com.rb.rest.services.system.RestException: Cannot parse XML document
Using the same XML, I am able to create the records using SoapUI
 
Is there perhaps a sample app somewhere, making use of the create and setBinaryData methods somewhere that I can look at?
 
Regards,
http://www.aigs.co.za/templates/email_signatures/2016/stephen_van_rooyen.png
 

Posted by stephen.vanrooyen on 07-Feb-2017 04:30

Hi,
 
I managed to get this working, but I had to resort to using the SOAP methods instead.
The setBinaryData() method seemed to have done the trick.
 
There seems to be a limitation on the HttpPost Trigger as it does not allow Tokens in the URL.
This meant I could not pass the sessionId to subsequent methods after login in.
 
Thanks again,
 
Regards,
http://www.aigs.co.za/templates/email_signatures/2016/stephen_van_rooyen.png
 

This thread is closed