Blogs

List Of Blogs > Custom Headless API in Liferay 7.4

Custom Headless API in Liferay 7.4

Umer Farooq


Custom Headless API in Liferay 7.4's

Introduction:

In this blog, we'll navigate the terrain of Liferay 7.4's Headless API, demystifying the process of implementing CRUD operations. From effortless data creation to seamless updates and deletions, this streamlined approach empowers developers with straightforward methods to interact with their application's data.

Okay I don’t want to waste your time, Imagine a scenario where managing student data - their Ids, names, and academic standards - becomes effortless. Enter Liferay 7.4's Headless API, offering a streamlined approach to handling CRUD operations within the Student entity created through the Service Builder.

Step 1:

  • Create entity into service.xml as shown in below image and an entity name as “student” then build the service after that create instance method in studentLocalServiceImpl.java then finally build the service and deploy it.

 

Step 2:

  • Create Headless API using rest-builder by liferay’s developer studio and then I gave it’s name as student-headless-delivery.

  • After click on finish it will create four folder as shown in below image and then delete “student-headless-delivery-client” and “student-headless-delivery-test”.

  • Into the student-headless-delivery-client -> rest-config.yaml file remove these line as shown in below image.

  • Add this dependency into student-headless-delivery-impl -> build.gradle file as show in below script.

  • After changes done in rest-openapi.yaml file then click the buildREST as shown in below image.

Step 3:

  • After buildREST it will create packages into student-headless-delivery-api and student-headless-delivery-impl then into the impl packages created like that as shown in below image.

  • After that add below script into "StudentResourceImpl.java student-headless-delivery-impl -> src/main/java -> com.student.headless.delivery.internal.resource.v1_0 -> StudentResourceImpl.java" (Click to get code StudentResourceImpl.java.)

  • Finally deploy that both student-headless-delivery-api and student-headless-delivery-impl jar files after builDREST.

 

Conclusion:

  • After our api demployment out-put will be like as shown in below images.

Now, it's your turn to put theory into practice and witness firsthand the transformative capabilities of Liferay 7.4's Headless API and Rest Builder in your development endeavors.



Categories


Archive