Tuesday, December 8, 2015

CRUD with ADF 12.2.1 ADF BC REST

I had a post about REST support by ADF BC in ADF 12.2.1 - ADF 12.2.1 ADF BC Support for REST. This was introduction, today I will go further and test CRUD (Create Read Update Delete) operations (using Postman REST client). Good news, CRUD are supported by ADF BC REST out of the box, there is no need to code anything. ADF BC REST services are well documented in ADF developer guide - 22 Consuming RESTful Web Services Using the ADF REST Framework.

Operations - Create, Update and Delete are available and enabled by default (see under section -Available Operations):


CREATE. ADF BC REST service is defined on top of Employees EO. I'm going to create new record in Employees table. We should use HTTP POST to insert new record. Very important is to specify Content-Type as application/vnd.oracle.adf.resourceitem+json, otherwise request will fail with parse error:


Data for the new record is supplied in raw format, mapping between row attributes (case sensitive) and attribute values:


New employee #999 record is inserted into DB:


READ. We can read data using HTTP GET operation. There is option to get row by key or you could query data by criteria. There is option to use Row Finder based on View Criteria. In this example I'm using query with criteria, searching for all employees with FirstName starting from J:


UPDATE. To update row data, we should use HTTP PATCH operation. You must provide key for the record and supply attribute/value pair to be updated. Content-Type as application/vnd.oracle.adf.resourceitem+json must be set for operation to succeed:


Salary value is updated in DB:


DELETE. To remove record, execute HTTP DELETE operation by row key:


Download sample application - ADFBCRestApp_v2.zip.

6 comments:

  1. Hi,

    If the rest services are secured, Can you please explain how we can attach policies in rest client.

    ReplyDelete
  2. Hi Andrejus,

    can we use this REST functionality in "ADF Essentials" version??

    ReplyDelete
  3. I will plan this as the next blog post topic.

    Regards,
    Andrejus

    ReplyDelete
  4. ADF BC REST and ADF Essentials - I would advice to ask this questions on OTN Forum. Oracle PM's should follow up.

    Regards,
    Andrejus

    ReplyDelete
  5. Hi Andrejus, Thanks for the post. I have created a REST web service from App module. Is it possible to send array of objects to PATCH operation instead of a single object? If yes, can you please let me know what changes I should do.

    Thanks,
    Anand.

    ReplyDelete
  6. Hi Andrejus,

    Have a question for the request to be successful you mentioned on the content-type to be application/vnd.oracle.adf.resourceitem+json. So if we are planning to consume this ADFBC REST service from SOA we would need to use SOA REST Adapter but in SOA this specific content type is not supported as this looks to be a specific content type so this content type is mandatory? any other workaround in using application/json content type as input.

    Regards,
    Kumaran

    ReplyDelete