A popular pattern is to esxtract data from other systems of record, like ERP Cloud or on-premise apps, and replicate it into VBCS business objects, then build extensions on that data using VBCS. Part of this pattern is to set up regular data sync jobs, using Oracle Integration Cloud orchestrations or some other tool, to sync the replicated data with the original data. We can do this using lifecycle REST APIs.
Summary
The basic flow of syncing data objects is:
- Acquire an OAuth authorization token using IDCS REST APIs. This token expires within one hour so you need to get a fresh token every time you want to do the data sync.
- Lock the running application so users can't edit data while it's being synced.
- Upload CSVs of the data.
- Unlock the application.
Getting an Authorization Token
All applications in the Oracle Cloud are authenticated using OAuth Apps in Identity Cloud Service. To get an authorization token, you have to find the OAuth App for the VBCS service instance and retrieve the Client ID and Secret. These are the credentials you will use to call the IDCS REST API to retrieve the authorization token.
Note that VBCS also creates a new OAuth App for each of the projects you create in VBCS. You need to find the OAuth App for VBCS itself, not for the app that you're trying to load data into.
- Go to the IDCS admin console at https://yourURL.identity.oraclecloud.com/ui/v1/adminconsole/?root=apps
- Find the OAuth App for the VBCS service instance. For example, if I have VBCS as part of an Autonomous Oracle Integration Cloud installation called MyOIC, then the app will be called IntegrationCloud_MyOIC. Note that the search field only searches for apps beginning with the search string, so searching for MyOIC will not return IntegrationCloud_MyOIC as a result.
- Click Configuration. In the General Information tab get the Client ID and Secret.
- Call the POST method on the httpsL//yourURL.identity.oraclecloud.com/oauth2/v1/token REST API with the following settings:
- Authorization: Basic auth, with the App ID as the user and the Key as the password
- Body:
- grant_type: password
- username: the user who you want to retrieve a token for. this user has to have access to the VBCS project that you want to access
- password: the password of the user above
- scope: the scope of the token. An example is https://D6BA0200D0614FFC1234510EAB70AF09.gbcom-south-1.oraclecloud.com:443urn:opc:resource:consumer::all. In this example, your App ID is D6BA0200D0614FFC1234510EAB70AF09_APPID and your VBCS server is https://MyOIC.gbcom-south-1.oraclecloud.com/ic/builder/. You remove the _AppID from the App ID for the first part of the domain, and you take the server info (everything after MyOIC) for the second part of the domain. The latter part of the scope says that this token can access any resource in the entire MyOIC domain. See the REST documentation for more info.
NOTE: On some instances the GUID may be different. To verify, get an access token manually from the VBCS UI and compare the settings. To do this, open the list of projects and for any project, click the application menu at the end of its row, then choose Settings. Go to the Security tab and click Get Access Token.
The REST API will return your token and say how long until it expires. Save the token as you'll use it in the REST calls to the VBCS project APIs.
Locking the VBCS Application
Now you need to lock the VBCS application so that users can't access it while you are syncing data. Call the following REST API:
- URL: https://myURL/ic/builder/deployment/appName/1.0/resources/application/lock/lock
- Method: POST
- Headers: Authentication: Bearer yourAccessToken
Syncing the Data
To update the data for an Employee business object, call the following REST API:
- URL: https://myURL/ic/builder/deployment/appName/1.0/resources/datamgr/import/Employee?filename=Employee.csv
- Method: POST
- Headers: Authentication: Bearer yourAccessToken
Unlocking the VBCS Application
Call the following REST API:
- URL: https://myURL/ic/builder/deployment/appName/1.0/resources/application/lock/unlock
- Method: POST
- Headers: Authentication: Bearer yourAccessToken