Friday, November 25, 2016

How to test APEX Restful Services



One of the power tools for testing Restful Services is DHC Rest Client that is Extension of Chrome browser, so it’s simple and easy. By this extension you able to save your project and any time you access to test it.


First of all I’ll add this extension to chrome and run it.


Create a Project e.g. oracle.example.hr after that create a REQUEST. You should add a request for each Template. In this sample I’ve used the sample data (oracle.example.hr) in Oracle APEX. It can be to set to follow this image


Project Name: oracle.example.hr
Request Name: employees
URL: https://apex.oracle.com/pls/xxxx/hr/employees/
Method: GET




First sample is ready to test, second sample will use {ID} and should be to add new REQUEST. After push Send button we can get some information and respond of Restful service such as {Body respond, Elapsed time, Header info and etc.}


Add a new REQUEST



When to push Send button


Now I want to add a new REQUEST with POST method so before I had created a  new Template insemp to sample Restful in oracle APEX.

RESTful Service Module: oracle.example.hr
URI Template: insemp/
Method: POST
Source Type: PL/SQL
Source:
begin
insert into emp(empno,ename) values(:ID,:NAME) returning EMPNO into :EMPNO;
commit;
end;


Parameters:
EMPNO  OUT  Response Body
ID            IN      HTTP Header
NAME    IN      HTTP Header


In DHC to set like this and when to click on Send button you ‘ll see below response.

Project Name: oracle.example.hr
Request Name: employees
URL: https://apex.oracle.com/pls/xxxx/hr/insemp/
Method: POST
HEADERS:
ID
NAME




4 comments :

  1. Hello Saeed,

    I am trying to raise a QUALITY Oracle Apex WhatsApp group (no spam, ads, bla bla) I am my self dev of apex of at least 3 - 5 years).

    please join : https://www.grupya.com/group/265/oracle-apex-whatsapp-group

    please spread it as well :-)
    Ety G

    ReplyDelete
  2. Hi!

    I'm trying to do this example with another data. What is supposed to go in the blurred section in the URL? In apex terms please.

    Thanks

    ReplyDelete
    Replies
    1. Hi,

      The blur section is only workspace-name, look at the below example

      URI: http://myhost/context-root/workspace-name/module/template
      e.g: https://apex.oracle.com/pls/apex/test/hr/employee

      Delete