Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Exporting and Importing Data From VBCS With REST Calls

DZone's Guide to

Exporting and Importing Data From VBCS With REST Calls

See how you can move data into and out of your Oracle Visual Build Cloud Service apps in Dev or Prod using some REST calls from the command line.

· Cloud Zone ·
Free Resource

See why enterprise app developers love Cloud Foundry. Download the 2018 User Survey for a snapshot of Cloud Foundry users’ deployments and productivity.

Visual Builder Cloud Service (VBCS) makes it very easy to create custom objects to store your data. A frequent request we get is for a way to load and export data from these business objects. As John Ceccarelli blogged, we added a feature to support doing this through the command line — John's blog shows you the basic options for the command line.

I recently needed to do this for a customer and thought I'd share some tips that helped me get the functionality working properly in case others need some help skipping bumps in the road.

Here is a demo showing both import and export and how to get them to work.


Exporting Data

Export is quite simple — you use a GET operation on a REST service. The command line for calling this using curl will look like this:

curl -u user:password https://yourserver/design/ExpImp/1.0/resources/datamgr/export > exp.zip


The result is a streaming of a ZIP file, so I just added a > exp.zip file to the command's end. The zip file will contain CSV files for each object in your application.

Don't forget to replace the bold things with your values for username and password, your VBCS server name and the name of the app you are using (ExpImp in my case).

Importing Data

Having the exported CSV file makes it easy to build a CSV file for upload — in the demo, I just replaced and added values in that file. Next, you'll use a similar curl command to call a POST method. It will look like this:

curl -X POST -u user:password https://yourserver/design/ExpImp/1.0/resources/datamgr/import/Employee?filename=Employee.csv -H "Origin:https://yourserver" -H "Content-Type:text/csv" -T Employee.csv -v


A few things to note.

You need to specify which object you want to import into (Employee after the /import/ in the command above), and you also need to provide a filename parameter that tells VBCS which file to import.

In the current release, you need to work around a CORS security limitation — this is why we are adding a header (with the -H option) that indicates that we are sending this from the same server as the one we are running on. In an upcoming version, this won't be needed.

We use the -T option to attach the CSV file to our call.

Note that you should enable the "Enable basic authentication for business object REST APIs" security option for the application (Under Application Settings->Security).

Using Import in Production Apps

In the samples above, we imported and exported into an application that is still being developed — this is why we used the /design/ in our REST path.

If you want to execute things on an application that you published, then replace the /design/ with /deployment/

One special note about live applications: Before you import data into them, you'll need to lock them. You can do this from the home page of VBCS and the drop-down menu on the application.

Cloud Foundry saves app developers $100K and 10 weeks on average per development cycle. Download the 2018 User Survey for a snapshot of Cloud Foundry users’ deployments and productivity. Find out what people love about the industry standard cloud application platform.

Topics:
cloud ,oracle visual builder cloud service ,rest ,data import ,data export ,tutorial

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}