Search This Blog

Tuesday, October 18, 2022

API Calling From Oracle Apex Using JavaScript

1. Create a blank page then create a region.

2. Create two items (Like P46_URL and P46_RESPONSE) , One for inputting web service URL and another one is for getting response. 

3. Copy-pest the below JavaScript function into page propertice> 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;

}

function callbackFunction(xmlhttp) 

{

 // alert(xmlhttp.responseXML);

}

4. Create a button and create a Dynamic Action on click event the button with Execute JavaScript Action. just call the function below. 

CALL_TO_WEBSERVICE();

5. That's All. Now just put the Web Service URL into the URL item and click on the button. 

No comments:

Post a Comment

Restrict File Upload by File Type in Oracle Apex

If you want to restrict file upload by file type/extension/format you can follow the below steps.  Goto File Browser Item --> Advanced --...