This is a very simple demonstration that shows how to use Rest Template with Spring Boot. In this example, I will create Java APIs,
To make it done, I'm using another REST application to work as a service. You can clone it using the following git repository. This can be any application that creates REST APIs, maybe Java, PHP, Python or whatever.
https://github.com/raviyasas/SpringBoot-REST-API-demo.git
This application will run on port 8090. Please read the ReadMe file for API details. Now I am going to create another Spring Boot application to call those APIs using Rest Template.
You can use the following curl command to GET, POST, PATCH and DELETE data. My application is running on port 8088, by default it will run on port 8080. You can change it by setting server. port =8088 at application.properties
Get user data
Add a new user
"
"
}' 'http://localhost:8088/api/v2/users/postData/'
Update a user
"
}' 'http://localhost:8088/api/v2/users/patchData/2'
Remove a user
You can download the complete project from here.
https://github.com/raviyasas/SpringBoot-RestTemplate-demo.git
How to use Rest Template with Spring Boot
Reviewed by Ravi Yasas
on
2:56 PM
Rating:
No comments: