venerdì 13 maggio 2016

Oracle Rest Data Service & Oracle Cloud (Second Part): How to INSERT (POST) data with REST

In the [FIRST] part you have learned how to create a REST Data Service in Oracle Database (in Cloud)

We have create a SELECT (GET), now we will see how to create an INSERT (POST).

You can use the "auto rest" (more info here) but with this you can do only simple insert, with primary key and only a "select * ..." if you would like to specialized your INSERT (or UPDATE or DELETE) you must do what I will explain in this post.

We will create a Data Service that will insert a row in the "emp" table of the HR user:

This is the configuration:
Insert in the Source field your preferred insert:

    insert into emp (empno,ename,job,hiredate,sal,deptno) values   

This is an example, you can write every kind of complex insert.

 Now you can test it, I suggest to use something like "Postman":

use your url in the POST field:

Set in the Headers tab:
Content-Type: application/json

Select the Body tab and put here the data to send:


Click the "Send" button:
If all It is ok, you will receive a Status 200 OK

If you refresh SQL Developer you can find the new row:

6 commenti: