Discussions
Categories
- 197.1K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.7K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 555 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.3K SQL Developer
- 296.3K Development
- 17 Developer Projects
- 139 Programming Languages
- 293K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 158 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 466 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
Using data from REST POST API with OJ Table

JET Version: 10.0
Hi JET Community
We have a requirement to fetch data from a REST API that requires information sent to it as a HTTP POST and serve it up in an OJ Table (appreciating that the API does not conform to REST principles in that it should really be a GET). This is due to the complexity of the payload required to filter the data from the service.
Typically with JET 10.x, we would use OJ Collection and OJ Model with OJ Table to give us light-weight data fetching along all the nice paging for free. Given that this is a POST, we cannot do that (unless anyone has a bright ideas on this).
Therefore, we would typically look to use ArrayDataProvider or MutableArrayDataProvider to help us here where we would pre-load the data provider in one hit. Unfortunately, we could be dealing with fairly large data sets and therefore don’t want to be fetching all the data over the network in one go. The API does support fetch size and offset in the POST payload so we need to work out how to leverage that with the table itself.
We were thinking therefore that we could listen for an event which indicated that the user had scrolled down past the watermark which triggers the data provider to do a fetch and then perform the POST request with the relevant offset and fetch size. We would then load that into the underlying array backing the data provider.
We have been looking through the API’s and the Cookbook but can’t see a pattern for this.
Does anyone have any ideas?
Many thanks
Best Answer
-
Hi Dave, you can still use the Common Model API with a POST method. Just us a customURL and set the method to POST instead of the default of GET. Take a look at this Cookbook demo paghttps://www.oracle.com/webfolder/technetwork/jet/jetCookbook.html?component=custom&demo=customURL
Answers
-
Hi Dave, you can still use the Common Model API with a POST method. Just us a customURL and set the method to POST instead of the default of GET. Take a look at this Cookbook demo paghttps://www.oracle.com/webfolder/technetwork/jet/jetCookbook.html?component=custom&demo=customURL
-
Hi John.
Thanks for your reply.
This is exactly what we need and it works perfectly.
Will the same outcome be able to be achieved with RESTDataProvider should we upgrade and use that in place of CollectionDataProvider in the future?
For reference to the wider community, if you were using the above approach with a POST, you would pass the payload in the 'data' attribute.
this.getURL = (operation, collection, options) => { let data = { "whatever is required": "for the API", }; const retObj = {}; retObj["type"] = "POST"; retObj["url"] = "https://.."; retObj["data"] = JSON.stringify(data); // + Other properties passed by Collection to the AJAX call as required return retObj; };
-
The RESTDataProvider can be edited to use a method POST instead of GET as well if you like. The fetchFirst method of the RESTDataProvider creates a new Request object, which is a standard HTTP request object that you can set the properties of.
This Learning Path was updated with the JET v12 release to use RESTDataProvider in a CRUD use case. It may be valuable to review. https://docs.oracle.com/en/middleware/developer-tools/jet/12.1/webapplications.html
-
Really helpful - thanks John.
This is a real ‘get out of jail’ card for us!