Javatpoint Logo
Javatpoint Logo

Implementing POST Service to Create a Post for a User

In this section, we will enable post-operation to create a post for the specific user.

Step 1: Open the UserJPAResource.java file and create a PostMapping to create a post.

Step 2: Create a post repository.

PostRepository.java

Step 3: Open the Postman and send a POST request with the URI http://localhost:8080/jpa/users/102/posts. Under the Body tab, insert the post description.

Implementing POST Service to Create a Post for a User

It returns the Status: 201 Created. We can also see this post in the database by executing the query select *from post;

Implementing POST Service to Create a Post for a User







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA