{"id":1334,"date":"2022-09-12T01:59:38","date_gmt":"2022-11-06T19:02:07","guid":{"rendered":"https:\/\/www.silicloud.com\/blog\/uncategorized\/example-of-how-to-use-resttemplate-in-spring\/"},"modified":"2024-03-16T15:50:36","modified_gmt":"2024-03-16T15:50:36","slug":"example-of-how-to-use-resttemplate-in-spring","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/","title":{"rendered":"Example of how to use RestTemplate in Spring"},"content":{"rendered":"<p>Spring RestTemplate offers a convenient method to conduct testing on RESTful web services.<\/p>\n<h2>The RestTemplate for <a href=\"https:\/\/spring.io\/\">Spring<\/a>.<\/h2>\n<ul class=\"post-ul\">\n<li>Spring RestTemplate class is part of spring-web, introduced in Spring 3.<\/li>\n<li>We can use RestTemplate to test HTTP based restful web services, it doesn\u2019t support HTTPS protocol.<\/li>\n<li>RestTemplate class provides overloaded methods for different HTTP methods, such as GET, POST, PUT, DELETE etc.<\/li>\n<\/ul>\n<h3>Example of using Spring RestTemplate<\/h3>\n<p>Let&#8217;s examine an example of Spring&#8217;s RestTemplate, where we will be testing REST web services from the previous Spring Data JPA article. The table below displays the URIs that are supported by this REST web service.<\/p>\n<div>\n<div class=\"post-table\">\n<table>\n<thead>\n<tr>\n<th>URI<\/th>\n<th>HTTP Method<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\/springData\/person<\/td>\n<td>GET<\/td>\n<td>Get all persons from database<\/td>\n<\/tr>\n<tr>\n<td>\/springData\/person\/{id}<\/td>\n<td>GET<\/td>\n<td>Get person by id<\/td>\n<\/tr>\n<tr>\n<td>\/springData\/person<\/td>\n<td>POST<\/td>\n<td>Add person to database<\/td>\n<\/tr>\n<tr>\n<td>\/springData\/person<\/td>\n<td>PUT<\/td>\n<td>Update person<\/td>\n<\/tr>\n<tr>\n<td>\/springData\/person\/{id}<\/td>\n<td>DELETE<\/td>\n<td>Delete person by id<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655dcae5cdcf9b6757a00805\/6-0.png\" alt=\"Spring RestTemplate Example\" \/><\/div>\n<h3>Dependencies for Maven for Spring RestTemplate.<\/h3>\n<p>To utilize the spring framework, we require dependencies like spring-core and spring-context. Furthermore, for the RestTemplate class, we need the spring-web artifact. Additionally, to enable Spring&#8217;s JSON support via the Jackson API, we need jackson-mapper-asl.<\/p>\n<pre class=\"post-pre\"><code>&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;project xmlns=\"https:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"https:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n\txsi:schemaLocation=\"https:\/\/maven.apache.org\/POM\/4.0.0 https:\/\/maven.apache.org\/xsd\/maven-4.0.0.xsd\"&gt;\r\n\t&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\r\n\r\n\t&lt;groupId&gt;com.scdev.spring&lt;\/groupId&gt;\r\n\t&lt;artifactId&gt;SpringRestTemplate&lt;\/artifactId&gt;\r\n\t&lt;version&gt;1.0-SNAPSHOT&lt;\/version&gt;\r\n\t&lt;properties&gt;\r\n\t\t&lt;spring.framework&gt;4.3.0.RELEASE&lt;\/spring.framework&gt;\r\n\t\t&lt;spring.web&gt;3.0.2.RELEASE&lt;\/spring.web&gt;\r\n\t\t&lt;serializer.version&gt;2.8.1&lt;\/serializer.version&gt;\r\n\t&lt;\/properties&gt;\r\n\t&lt;dependencies&gt;\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;org.springframework&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;spring-core&lt;\/artifactId&gt;\r\n\t\t\t&lt;version&gt;${spring.framework}&lt;\/version&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;org.springframework&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;spring-context&lt;\/artifactId&gt;\r\n\t\t\t&lt;version&gt;${spring.framework}&lt;\/version&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;org.codehaus.jackson&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;jackson-mapper-asl&lt;\/artifactId&gt;\r\n\t\t\t&lt;version&gt;1.9.4&lt;\/version&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupId&gt;org.springframework&lt;\/groupId&gt;\r\n\t\t\t&lt;artifactId&gt;spring-web&lt;\/artifactId&gt;\r\n\t\t\t&lt;version&gt;${spring.web}&lt;\/version&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\t&lt;\/dependencies&gt;\r\n&lt;\/project&gt;\r\n<\/code><\/pre>\n<h3>Class for configuring Spring.<\/h3>\n<p>In order to configure the RestTemplate class, we need to create a spring bean which is accomplished within the AppConfig class.<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.spring.config;\r\n\r\nimport org.codehaus.jackson.map.ObjectMapper;\r\nimport org.springframework.context.annotation.Bean;\r\nimport org.springframework.context.annotation.ComponentScan;\r\nimport org.springframework.context.annotation.Configuration;\r\nimport org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;\r\nimport org.springframework.web.client.RestTemplate;\r\n\r\n@Configuration\r\n@ComponentScan(\"com.scdev.spring\")\r\npublic class AppConfig {\r\n\r\n\t@Bean\r\n\tRestTemplate restTemplate() {\r\n\t\tRestTemplate restTemplate = new RestTemplate();\r\n\t\tMappingJacksonHttpMessageConverter converter = new MappingJacksonHttpMessageConverter();\r\n\t\tconverter.setObjectMapper(new ObjectMapper());\r\n\t\trestTemplate.getMessageConverters().add(converter);\r\n\t\treturn restTemplate;\r\n\t}\r\n}\r\n<\/code><\/pre>\n<p>Please be aware that RestTamplate utilizes a MessageConverter and we must configure this property in the RestTemplate bean. In the given instance, we are using MappingJacksonHttpMessageConverter to retrieve data in the JSON format.<\/p>\n<h3>Class for a specific model<\/h3>\n<p>To convert the JSON received from our web service to a java object using the jackson mapper, it is necessary to develop a model class specifically for this purpose. It should be noted that this model class will closely resemble the one used in the web service, with the exception that JPA annotations are not required in this case.<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.spring.model;\r\n\r\npublic class Person {\r\n\r\n\tprivate Long id;\r\n\r\n\tprivate Integer age;\r\n\r\n\tprivate String firstName;\r\n\r\n\tprivate String lastName;\r\n\r\n\tpublic Person() {\r\n\t}\r\n\r\n\tpublic Long getId() {\r\n\t\treturn id;\r\n\t}\r\n\r\n\tpublic void setId(Long id) {\r\n\t\tthis.id = id;\r\n\t}\r\n\r\n\tpublic Integer getAge() {\r\n\t\treturn age;\r\n\t}\r\n\r\n\tpublic void setAge(Integer age) {\r\n\t\tthis.age = age;\r\n\t}\r\n\r\n\tpublic String getFirstName() {\r\n\t\treturn firstName;\r\n\t}\r\n\r\n\tpublic void setFirstName(String firstName) {\r\n\t\tthis.firstName = firstName;\r\n\t}\r\n\r\n\tpublic String getLastName() {\r\n\t\treturn lastName;\r\n\t}\r\n\r\n\tpublic void setLastName(String lastName) {\r\n\t\tthis.lastName = lastName;\r\n\t}\r\n\r\n\t@Override\r\n\tpublic String toString() {\r\n\t\treturn \"Person{\" + \"id=\" + id + \", age=\" + age + \", firstName='\" + firstName + '\\'' + \", lastName='\" + lastName\r\n\t\t\t\t+ '\\'' + '}';\r\n\t}\r\n}\r\n<\/code><\/pre>\n<h3>The Class for the RestTemplate Client in Spring.<\/h3>\n<p>The last task is to generate the client classes which will utilize the previously defined RestTemplate bean.<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.spring.config;\r\n\r\nimport java.util.List;\r\n\r\nimport org.springframework.http.HttpStatus;\r\n\r\nimport com.scdev.spring.model.Person;\r\n\r\npublic interface PersonClient {\r\n\tList&lt;Person&gt; getAllPerson();\r\n\r\n\tPerson getById(Long id);\r\n\r\n\tHttpStatus addPerson(Person person);\r\n\r\n\tvoid updatePerson(Person person);\r\n\r\n\tvoid deletePerson(Long id);\r\n}\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>package com.scdev.spring.config;\r\n\r\nimport java.util.Arrays;\r\nimport java.util.List;\r\n\r\nimport org.springframework.beans.factory.annotation.Autowired;\r\nimport org.springframework.http.HttpStatus;\r\nimport org.springframework.http.ResponseEntity;\r\nimport org.springframework.stereotype.Service;\r\nimport org.springframework.web.client.RestTemplate;\r\n\r\nimport com.scdev.spring.model.Person;\r\n\r\n@Service\r\npublic class PersonClientImpl implements PersonClient {\r\n\r\n\t@Autowired\r\n\tRestTemplate restTemplate;\r\n\r\n\tfinal String ROOT_URI = \"https:\/\/localhost:8080\/springData\/person\";\r\n\r\n\tpublic List&lt;Person&gt; getAllPerson() {\r\n\t\tResponseEntity&lt;Person[]&gt; response = restTemplate.getForEntity(ROOT_URI, Person[].class);\r\n\t\treturn Arrays.asList(response.getBody());\r\n\r\n\t}\r\n\r\n\tpublic Person getById(Long id) {\r\n\t\tResponseEntity&lt;Person&gt; response = restTemplate.getForEntity(ROOT_URI + \"\/\"+id, Person.class);\r\n\t\treturn response.getBody();\r\n\t}\r\n\r\n\tpublic HttpStatus addPerson(Person person) {\r\n\t\tResponseEntity&lt;HttpStatus&gt; response = restTemplate.postForEntity(ROOT_URI, person, HttpStatus.class);\r\n\t\treturn response.getBody();\r\n\t}\r\n\r\n\tpublic void updatePerson(Person person) {\r\n\t\trestTemplate.put(ROOT_URI, person);\r\n\t}\r\n\r\n\tpublic void deletePerson(Long id) {\r\n\t\trestTemplate.delete(ROOT_URI + id);\r\n\r\n\t}\r\n}\r\n<\/code><\/pre>\n<p>We invoke RestTemplate methods by considering the URI and the HTTP method, and we pass the suitable request object if necessary. The code is easily comprehensible.<\/p>\n<h3>TestClass for testing Spring RestTemplate.<\/h3>\n<p>Now is the moment to evaluate our Spring RestTemplate example project. The following class demonstrates the utilization of RestTemplate methods in a Spring manner.<\/p>\n<pre class=\"post-pre\"><code>package com.scdev.spring;\r\n\r\nimport org.springframework.context.annotation.AnnotationConfigApplicationContext;\r\nimport org.springframework.http.HttpStatus;\r\n\r\nimport com.scdev.spring.config.AppConfig;\r\nimport com.scdev.spring.config.PersonClient;\r\nimport com.scdev.spring.model.Person;\r\n\r\npublic class Main {\r\n\r\n\tpublic static void main(String[] args) {\r\n\t\tAnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(AppConfig.class);\r\n\r\n\t\tPersonClient client = applicationContext.getBean(PersonClient.class);\r\n\r\n\t\tSystem.out.println(\"Getting list of all people:\");\r\n\r\n\t\tfor (Person p : client.getAllPerson()) {\r\n\t\t\tSystem.out.println(p);\r\n\t\t}\r\n\r\n\t\tSystem.out.println(\"\\nGetting person with ID 2\");\r\n\r\n\t\tPerson personById = client.getById(2L);\r\n\r\n\t\tSystem.out.println(personById);\r\n\r\n\t\tSystem.out.println(\"Adding a Person\");\r\n\t\tPerson p = new Person();\r\n\t\tp.setAge(50);\r\n\t\tp.setFirstName(\"David\");\r\n\t\tp.setLastName(\"Blain\");\r\n\t\tHttpStatus status = client.addPerson(p);\r\n\t\tSystem.out.println(\"Add Person Response = \" + status);\r\n\r\n\t\tapplicationContext.close();\r\n\t}\r\n}\r\n<\/code><\/pre>\n<p>Once I execute the program on my local configuration, I receive the ensuing output.<\/p>\n<pre class=\"post-pre\"><code>Getting list of all people:\r\nPerson{id=2, age=30, firstName='Oksi', lastName=' Bahatskaya'}\r\nPerson{id=1, age=30, firstName='Vlad', lastName='Mateo'}\r\n\r\nGetting person with ID 2\r\nPerson{id=2, age=30, firstName='Oksi', lastName=' Bahatskaya'}\r\nAdding a Person\r\nAdd Person Response = 201\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655dcae5cdcf9b6757a00805\/27-0.png\" alt=\"Spring RestTemplate\" \/><\/div>\n<p>Get the Spring RestTemplate Example Project for download.<\/p>\n<p>Source: API Documentation<\/p>\n<p>&nbsp;<\/p>\n<p>More tutorials<\/p>\n<p><a class=\"LinkSuggestion__Link-sc-1gewdgc-4 cLBplk\" href=\"https:\/\/www.silicloud.com\/blog\/spring-mvc-controller\/\" target=\"_blank\" rel=\"noopener\">Spring MVC Controller<span class=\"sc-gswNZR eASTkv\">(Opens in a new browser tab)<\/span><\/a><\/p>\n<p><a class=\"LinkSuggestion__Link-sc-1gewdgc-4 cLBplk\" href=\"https:\/\/www.silicloud.com\/blog\/dependency-injection-in-spring\/\" target=\"_blank\" rel=\"noopener\">Dependency Injection in Spring<span class=\"sc-gswNZR eASTkv\">(Opens in a new browser tab)<\/span><\/a><\/p>\n<p><a class=\"LinkSuggestion__Link-sc-1gewdgc-4 cLBplk\" href=\"https:\/\/www.silicloud.com\/blog\/the-spring-framework\/\" target=\"_blank\" rel=\"noopener\">The Spring Framework<span class=\"sc-gswNZR eASTkv\">(Opens in a new browser tab)<\/span><\/a><\/p>\n<p><a class=\"LinkSuggestion__Link-sc-1gewdgc-4 cLBplk\" href=\"https:\/\/www.silicloud.com\/blog\/spring-webflux-refers-to-the-reactive-programming-model-provided-by-the-spring-framework-for-building-web-applications\/\" target=\"_blank\" rel=\"noopener\">Spring WebFlux the Spring Reactive Programming<span class=\"sc-gswNZR eASTkv\">(Opens in a new browser tab)<\/span><\/a><\/p>\n<p><a class=\"LinkSuggestion__Link-sc-1gewdgc-4 cLBplk\" href=\"https:\/\/www.silicloud.com\/blog\/spring-component-annotation\/\" target=\"_blank\" rel=\"noopener\">Spring Component annotation<span class=\"sc-gswNZR eASTkv\">(Opens in a new browser tab)<\/span><\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spring RestTemplate offers a convenient method to conduct testing on RESTful web services. The RestTemplate for Spring. Spring RestTemplate class is part of spring-web, introduced in Spring 3. We can use RestTemplate to test HTTP based restful web services, it doesn\u2019t support HTTPS protocol. RestTemplate class provides overloaded methods for different HTTP methods, such as [&hellip;]<\/p>\n","protected":false},"author":11,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-1334","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Example of how to use RestTemplate in Spring - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"RestTemplate class provides overloaded methods for different HTTP methods, such as GET, POST, PUT, DELETE etc.Example of using Spring\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Example of how to use RestTemplate in Spring\" \/>\n<meta property=\"og:description\" content=\"RestTemplate class provides overloaded methods for different HTTP methods, such as GET, POST, PUT, DELETE etc.Example of using Spring\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-11-06T19:02:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-16T15:50:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655dcae5cdcf9b6757a00805\/6-0.png\" \/>\n<meta name=\"author\" content=\"Olivia Parker\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:site\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Olivia Parker\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/\"},\"author\":{\"name\":\"Olivia Parker\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/3ff7b3da0e45ac5dbbef2502f3cea8d9\"},\"headline\":\"Example of how to use RestTemplate in Spring\",\"datePublished\":\"2022-11-06T19:02:07+00:00\",\"dateModified\":\"2024-03-16T15:50:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/\"},\"wordCount\":473,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/\",\"name\":\"Example of how to use RestTemplate in Spring - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\"},\"datePublished\":\"2022-11-06T19:02:07+00:00\",\"dateModified\":\"2024-03-16T15:50:36+00:00\",\"description\":\"RestTemplate class provides overloaded methods for different HTTP methods, such as GET, POST, PUT, DELETE etc.Example of using Spring\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.silicloud.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Example of how to use RestTemplate in Spring\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"name\":\"Silicon Cloud Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\",\"name\":\"Silicon Cloud Blog\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"contentUrl\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"width\":1024,\"height\":1024,\"caption\":\"Silicon Cloud Blog\"},\"image\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\",\"https:\/\/twitter.com\/SiliCloudGlobal\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/3ff7b3da0e45ac5dbbef2502f3cea8d9\",\"name\":\"Olivia Parker\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/56c66f189ba32a6f9eb50f31a38fe774e2a725c213d4070835ccc51b8fbbc54b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/56c66f189ba32a6f9eb50f31a38fe774e2a725c213d4070835ccc51b8fbbc54b?s=96&d=mm&r=g\",\"caption\":\"Olivia Parker\"},\"url\":\"https:\/\/www.silicloud.com\/blog\/author\/oliviaparker\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Example of how to use RestTemplate in Spring - Blog - Silicon Cloud","description":"RestTemplate class provides overloaded methods for different HTTP methods, such as GET, POST, PUT, DELETE etc.Example of using Spring","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/","og_locale":"en_US","og_type":"article","og_title":"Example of how to use RestTemplate in Spring","og_description":"RestTemplate class provides overloaded methods for different HTTP methods, such as GET, POST, PUT, DELETE etc.Example of using Spring","og_url":"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/","og_site_name":"Blog - Silicon Cloud","article_publisher":"https:\/\/www.facebook.com\/SiliCloudGlobal\/","article_published_time":"2022-11-06T19:02:07+00:00","article_modified_time":"2024-03-16T15:50:36+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/655dcae5cdcf9b6757a00805\/6-0.png"}],"author":"Olivia Parker","twitter_card":"summary_large_image","twitter_creator":"@SiliCloudGlobal","twitter_site":"@SiliCloudGlobal","twitter_misc":{"Written by":"Olivia Parker","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/#article","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/"},"author":{"name":"Olivia Parker","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/3ff7b3da0e45ac5dbbef2502f3cea8d9"},"headline":"Example of how to use RestTemplate in Spring","datePublished":"2022-11-06T19:02:07+00:00","dateModified":"2024-03-16T15:50:36+00:00","mainEntityOfPage":{"@id":"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/"},"wordCount":473,"commentCount":0,"publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/","url":"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/","name":"Example of how to use RestTemplate in Spring - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/#website"},"datePublished":"2022-11-06T19:02:07+00:00","dateModified":"2024-03-16T15:50:36+00:00","description":"RestTemplate class provides overloaded methods for different HTTP methods, such as GET, POST, PUT, DELETE etc.Example of using Spring","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/blog\/example-of-how-to-use-resttemplate-in-spring\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.silicloud.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Example of how to use RestTemplate in Spring"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/blog\/#website","url":"https:\/\/www.silicloud.com\/blog\/","name":"Silicon Cloud Blog","description":"","publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.silicloud.com\/blog\/#organization","name":"Silicon Cloud Blog","url":"https:\/\/www.silicloud.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","contentUrl":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","width":1024,"height":1024,"caption":"Silicon Cloud Blog"},"image":{"@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/SiliCloudGlobal\/","https:\/\/twitter.com\/SiliCloudGlobal"]},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/3ff7b3da0e45ac5dbbef2502f3cea8d9","name":"Olivia Parker","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/56c66f189ba32a6f9eb50f31a38fe774e2a725c213d4070835ccc51b8fbbc54b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/56c66f189ba32a6f9eb50f31a38fe774e2a725c213d4070835ccc51b8fbbc54b?s=96&d=mm&r=g","caption":"Olivia Parker"},"url":"https:\/\/www.silicloud.com\/blog\/author\/oliviaparker\/"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/1334","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/comments?post=1334"}],"version-history":[{"count":0,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/1334\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/media?parent=1334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/categories?post=1334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/tags?post=1334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}