DEV Community

Naveen
Naveen

Posted on

Calling GET API & Mapping Response in VBCS (Service Connection)

In Oracle VBCS, integrating a GET API and displaying its response on the UI is one of the most common use cases. In this blog, we’ll walk through how to:

  • Create a GET API (ORDS)
  • Configure Service Connection in VBCS
  • Call API using Event Trigger
  • Map API response to UI components

1. Sample GET API (ORDS)

Let’s first create a simple GET API to fetch data from nj_dump(NJ_DUMP is a table).

Below is code snippet for the creations GET API using PLSQL

BEGIN
  ORDS.define_template(
    p_module_name => 'nj_api',
    p_pattern     => 'get_data'
  );
END;
/

BEGIN
  ORDS.define_handler(
    p_module_name => 'nj_api',
    p_pattern     => 'get_data',
    p_method      => 'GET',
    p_source_type => ORDS.source_type_query,
    p_source      => '
      SELECT name, num, dob, email
      FROM nj_dump
      WHERE num = nvl(:num,num)
    '
  );
END;
/
Enter fullscreen mode Exit fullscreen mode

ENDPOINT looks like
GET /ords//nj_api/get_data?num=101
Before moving to VBCS kindly test it in POSTMAN or Curl
Note: I prefer Basic Authorization.

2. Create Service Connection in VBCS
Navigations: Go to Services → Service Connections→ Chose define by endpoint
Click Create
Enter: respective Details


3. Add GET Endpoint
Paste your respectively GET URL in the below bar & proceed next


Once you done with GET REQUEST endpoint , you will able to see like this


4. Create Page Variables
Under Web apps we will create type & variables.
type
Hope you choose the type from endpoint
you will your endpoints here like this, pick get for our case.

In the next step we have to select the needed column to display in the VBCS UI

successfully create type, it will help us to create variable in the next page.

Now go to variables & create variable, make sure select the type which you created earlier.

5.Assign Variables to the form/page

I created form layout, if code needed, I would provide you at end of blog.

In the same manner add all variables to the respective columns in the form.

6. Call GET API Using Event Trigger
Now whenever we hit the Search button, The get REST endpoint will be called return the data to form.

For that we need to create an event action trigger there we will assign the get endpoint & collect the response from it and assign the same type.

7. Pass Query Parameter
choose the respective actions here & map the num Variable to the GET API endpoint


Mapper reference

8. Testing
Working as expected:

9. End-to-End Flow

  • User enters num
  • Event Trigger fires (button / field change)
  • GET API is called via Service Connection
  • Data is fetched from DB
  • Response stored in apiResponse
  • UI automatically updates

We successfully completed GET API calling in VBCS with help of Service connection & on button event trigger.

Try with Variable onValueChanged Event instead of button

Form code:

Top comments (1)

Collapse
 
bhargavi_harish_7611ccaf6 profile image
Bhargavi Harish

Detailed explanation Good Job Naveen.