What is the OData
OData (Open Data Protocol) is an ISO/IEC approved, OASIS standard that defines a set of best practices for building and consuming RESTful APIs. OData helps you focus on your business logic while building RESTful APIs without having to worry about the various approaches to define request and response headers, status codes, HTTP methods, URL conventions, media types, payload formats, query options, etc. OData also provides guidance for tracking changes, defining functions/actions for reusable procedures, and sending asynchronous/batch requests (source: OData.org).
The OData use cases
- Deploy data as REST Services with an interoperable format without development effort;
- Allows BI, data visualization, ERP, CRM, ESB, Workflow tools and engines consume data using REST without development effort;
- Virtualize corporate data in API Management tools;
- OData advocates a standard way of implementing REST APIs that allows for SQL-like querying capabilities using these RESTful APIs. OData is essentially SQL for the web built n top of standard protocols – HTTP, JSON & ATOM – while leveraging the REST architecture style (progress.com);
- OData has a broad adoption, see:
- OData helps to implement FHIR: FHIR, or Fast Healthcare Interoperability Resources Specification, is a standard for exchanging healthcare information electronically. In order to make FHIR truly interoperable, it is recommended that systems use the rules specified by OData specification for the $search parameter. Further, FHIR also uses OAuth in order to establish a trusted relationship with the client for an extra layer of security (progress.com);
- OData supports pagination, batch requests and different formats like JSON, ATOM, XML, etc.
OData and InterSystems IRIS
The InterSystems IRIS does not support OData but is possible use the OData Server for InterSystems IRIS to allows expose Persistent classes as REST.
Follow these instructions:
- Clone the source code of the IRIS OData Server: git clone https://github.com/yurimarx/isc-iris-odata.git
- Go to: isc-iris-odata folder
- Execute: mvnw install (MS Windows) or ./mvnw install (linux or mac)
- Execute: docker build -t odata:1.0.0 .
- Execute: docker run -p 8080:8080 odata:1.0.0. Your OData Server started:
- Start your InterSystems IRIS instance with any persistent class, in my ca
- In your browser access: http://localhost:8080/. Set parameters on the screen:
- This is parameters to my instance. Set the parameters to your IRIS instance. In namespace set your iris namespace, in the schema, the SQL Table schema, and in the port, the port to your JDBC database connection.
- Press submit and RELOAD YOUR ODATA SERVER DOCKER INSTANCE TO APPLY PARAMETERS.
- Access http://localhost:8080/odata.svc/ to see all persistent classes to your IRIS schema. In my case is:
- To navigate to a persistent class browse: http://localhost:8080/odata.svc/<Persistent_Class> e.g.: http://localhost:8080/odata.svc/Animal
- The OData server list Animal data, see:
- To see in JSON format browse: http://localhost:8080/odata.svc/Animal?$format=application/json. See:
- To see details about a row browse: http://localhost:8080/odata.svc/Animal(8)?$format=application/json
- To delete send a DELETE in your postman with http://localhost:8080/odata.svc/Animal(8)
- To insert send a POST in your postman with http://localhost:8080/odata.svc/Animal and a JSON body with property name and value pairs, like:
- So you can do all CRUD operations with your persistent classes.
- Many other features will be released in the future, if IRIS OData Server get the community adoption.
Thanks!