1. Overview

This Document will Explain How to call a API using java script in oracle apex.

  1. Technologies and Tools Used

The following technology has been used to achieve the same.

 

1.Java script

2.Oracle Apex 22.1

  1. Use Case

It will help us to call a API in front end using java script in the easy manner instated of creating Rest data

source.

  1. Architecture.

Step 1 : Create a blank page and create a new region.

Step 2: Create two page item like

(P11_URLand P11_Response)

Step 3: One is for inputting web service

and another is for getting response

Step 4: Copy and paste the below javascript function into the page properties –> Function and global

variable declaration.

function CALL_TO_WEBSERVICE()

{

var urlvariable;

var ItemJSON;

var v_url = apex.item(“P46_URL”).getValue();

URL = v_url ;

var xmlhttp = new XMLHttpRequest();

xmlhttp.onreadystatechange = callbackFunction(xmlhttp);

xmlhttp.open(“GET”, URL, false);

xmlhttp.onreadystatechange = callbackFunction(xmlhttp);

xmlhttp.send(ItemJSON);

$x(“P46_RESPONSE”).value = xmlhttp.responseText;}

Step 5: Create a button.

Step 6:And create dynamic action on click event the button with execute javascript action.

Step 7: Then call the below function in it.

CALL_TO_WEBSERVICE();

Step 8: Then click save and run.

Step 9: That’s all. Now just put the web service URL into the URL item and click on the button call API.

Step 10: Output.

Recent Posts

Start typing and press Enter to search