{"id":95,"date":"2019-03-07T12:51:44","date_gmt":"2019-03-07T12:51:44","guid":{"rendered":"https:\/\/www.kindsonthegenius.com\/spring-boot\/?p=95"},"modified":"2020-07-26T08:13:13","modified_gmt":"2020-07-26T08:13:13","slug":"12-spring-boot-write-post-methods","status":"publish","type":"post","link":"https:\/\/www.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/","title":{"rendered":"Spring Boot &#8211; Write POST Methods"},"content":{"rendered":"<p>In this lesson we would write the post methods. This method would lets use insert new records. For example, create new user, new location and new post.<\/p>\n<p>&nbsp;<\/p>\n<ol>\n<li><a href=\"#t1\">Create New Location<\/a><\/li>\n<li><a href=\"#t2\">Install Advanced REST Client<\/a><\/li>\n<li><a href=\"#t3\">Test the POST Method<\/a><\/li>\n<li><a href=\"#t4\">Create new User<\/a><\/li>\n<li><a href=\"#t5\">Create new Post<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h4><strong id = \"t1\">1. Create New Location<\/strong><\/h4>\n<p>We start by creating a new location. To insert a new resource, the HTTP method will be POST. This would be added as part of the parameters to the RequestMapping annotation as show below.<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #555555; font-weight: bold;\">@RequestMapping<\/span>(method=RequestMethod.<span style=\"color: #0000cc;\">POST<\/span>, value=<span style=\"background-color: #fff0f0;\">\"\/locations\"<\/span>)\r\n    <span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">addLocation<\/span>() {\r\n\t\t\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>You can see that the url for inserting a new location is same as the url for getAllLocations. We used this <a href=\"https:\/\/www.kindsonthegenius.com\/spring-boot\/09-spring-boot-write-get-methods\/\">when we created the GET methods.<\/a><\/p>\n<p>The complete method is given below:<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #555555; font-weight: bold;\">@RequestMapping<\/span><span style=\"color: #333333;\">(<\/span>method<span style=\"color: #333333;\">=<\/span>RequestMethod<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">POST<\/span><span style=\"color: #333333;\">,<\/span> value<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"\/locations\"<\/span><span style=\"color: #333333;\">)<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">addLocation<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #555555; font-weight: bold;\">@RequestBody<\/span> Location location<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\tlocationService<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">addLocation<\/span><span style=\"color: #333333;\">(<\/span>location<span style=\"color: #333333;\">);<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Now, the addLocation() method have not been implemented in the LocationService. So you need to create this method in the LocationService class.<\/p>\n<p>Put the code below in the LocationService<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">addLocation<\/span><span style=\"color: #333333;\">(<\/span>Location location<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n     locations<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">add<\/span><span style=\"color: #333333;\">(<\/span>location<span style=\"color: #333333;\">);<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Next, we are going to test the post methods.To do this we would need a tool.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id = \"t2\">2. Install Advanced REST Client<\/strong><\/h4>\n<p>To make a POST request, we need to provide the data we want to insert. Since this is an API, we don&#8217;t have a HTML form to fill in this data.<\/p>\n<p>So to provide input, we need to use a tool called Advanced REST Client. This is a free plugin to Google Chrome.<\/p>\n<p>To install it, visit this link (<a href=\"https:\/\/chrome.google.com\/webstore\/detail\/advanced-rest-client\/hgmloofddffdnphfgcellkdfbfbjeloo\">Get Advanced REST Client<\/a>) and just install it. Next, launch it. The interface is as shown below. You can watch the video to see the procedure.<\/p>\n<p><a href=\"https:\/\/youtu.be\/KD36Yy9mMUE\">Watch the video of How to Use Advanced REST Client<\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-102 size-full\" src=\"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/REST-Client.jpg\" alt=\"\" width=\"1010\" height=\"653\" srcset=\"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/REST-Client.jpg 1010w, https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/REST-Client-300x194.jpg 300w, https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/REST-Client-768x497.jpg 768w\" sizes=\"auto, (max-width: 1010px) 100vw, 1010px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id = \"t3\">3. Test the POST Method<\/strong><\/h4>\n<p>Before you do the test, you need to make a little change to the locations variable in the LocationService class.<\/p>\n<p>Replace this existing location variables,<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">List<span style=\"color: #333333;\">&lt;<\/span>Location<span style=\"color: #333333;\">&gt;<\/span> locations <span style=\"color: #333333;\">=<\/span> Arrays<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">asList<\/span><span style=\"color: #333333;\">(<\/span>location1<span style=\"color: #333333;\">,<\/span> location2<span style=\"color: #333333;\">,<\/span> location3<span style=\"color: #333333;\">);<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>with this one;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">List<span style=\"color: #333333;\">&lt;<\/span>Location<span style=\"color: #333333;\">&gt;<\/span> locations <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> ArrayList<span style=\"color: #333333;\">&lt;&gt;(<\/span>Arrays<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">asList<\/span><span style=\"color: #333333;\">(<\/span>location1<span style=\"color: #333333;\">,<\/span> location2<span style=\"color: #333333;\">,<\/span> location3<span style=\"color: #333333;\">));<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>This would make it possible to modify the ArrayList<\/p>\n<p>Now, test the POST Method using Advanced REST Client.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id = \"t4\">4. Create New User<\/strong><\/h4>\n<p>Write the addUser method in the UserController class.<\/p>\n<p>In the controller file, replace the line:<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">private<\/span> List<span style=\"color: #333333;\">&lt;<\/span>User<span style=\"color: #333333;\">&gt;<\/span> users <span style=\"color: #333333;\">=<\/span> Arrays<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">asList<\/span><span style=\"color: #333333;\">(<\/span>user1<span style=\"color: #333333;\">,<\/span> user2<span style=\"color: #333333;\">);<\/span>\t\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>with this one<\/p>\n<p>&nbsp;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">private<\/span> List<span style=\"color: #333333;\">&lt;<\/span>User<span style=\"color: #333333;\">&gt;<\/span> users <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> ArrayList<span style=\"color: #333333;\">&lt;&gt;(<\/span>Arrays<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">asList<\/span><span style=\"color: #333333;\">(<\/span>user1<span style=\"color: #333333;\">,<\/span> user2<span style=\"color: #333333;\">));<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>The addUser method for the UserController class is given below. You can copy and paste it.<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #555555; font-weight: bold;\">@RequestMapping<\/span><span style=\"color: #333333;\">(<\/span>value<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">\"\/users\"<\/span><span style=\"color: #333333;\">,<\/span> method <span style=\"color: #333333;\">=<\/span> RequestMethod<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">POST<\/span><span style=\"color: #333333;\">)<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">addUser<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #555555; font-weight: bold;\">@RequestBody<\/span> User user<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n\tuserService<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">addUser<\/span><span style=\"color: #333333;\">(<\/span>user<span style=\"color: #333333;\">);<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Finally, place the addUser method for the UserService class<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">addUser<\/span><span style=\"color: #333333;\">(<\/span>User user<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n    users<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">add<\/span><span style=\"color: #333333;\">(<\/span>user<span style=\"color: #333333;\">);<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>You can then test the application using Advanced REST Client. Try to add a new User.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h4><strong id = \"t5\">5. Create New Post<\/strong><\/h4>\n<p>Finally, we would work on inserting a new Post. As before, replace this line in PostService<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">List<span style=\"color: #333333;\">&lt;<\/span>Post<span style=\"color: #333333;\">&gt;<\/span> posts <span style=\"color: #333333;\">=<\/span> Arrays<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">asList<\/span><span style=\"color: #333333;\">(<\/span>post1<span style=\"color: #333333;\">,<\/span> post2<span style=\"color: #333333;\">);<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>with this one:<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\">List<span style=\"color: #333333;\">&lt;<\/span>Post<span style=\"color: #333333;\">&gt;<\/span> posts <span style=\"color: #333333;\">=<\/span> <span style=\"color: #008800; font-weight: bold;\">new<\/span> ArrayList<span style=\"color: #333333;\">&lt;&gt;(<\/span>Arrays<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">asList<\/span><span style=\"color: #333333;\">(<\/span>post1<span style=\"color: #333333;\">,<\/span> post2<span style=\"color: #333333;\">));<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>The addPost method for the PostController class is as shown below<\/p>\n<p>&nbsp;<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #555555; font-weight: bold;\">@RequestMapping<\/span><span style=\"color: #333333;\">(<\/span>value <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">\"\/posts\"<\/span><span style=\"color: #333333;\">,<\/span> method <span style=\"color: #333333;\">=<\/span> RequestMethod<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">POST<\/span><span style=\"color: #333333;\">)<\/span>\r\n<span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">addPost<\/span><span style=\"color: #333333;\">(<\/span><span style=\"color: #555555; font-weight: bold;\">@RequestBody<\/span> Post post<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n     postService<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">addPost<\/span><span style=\"color: #333333;\">(<\/span>post<span style=\"color: #333333;\">);<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>The addPost method for the PostService class is as below:<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #008800; font-weight: bold;\">public<\/span> <span style=\"color: #333399; font-weight: bold;\">void<\/span> <span style=\"color: #0066bb; font-weight: bold;\">addPost<\/span><span style=\"color: #333333;\">(<\/span>Post post<span style=\"color: #333333;\">)<\/span> <span style=\"color: #333333;\">{<\/span>\r\n     posts<span style=\"color: #333333;\">.<\/span><span style=\"color: #0000cc;\">add<\/span><span style=\"color: #333333;\">(<\/span>post<span style=\"color: #333333;\">);<\/span>\r\n<span style=\"color: #333333;\">}<\/span>\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>At this point, you have completed the POST methods. Next, we are going to write the Update and Delete methods<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>In this lesson we would write the post methods. This method would lets use insert new records. For example, create new user, new location and &hellip; <!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":1,"featured_media":104,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-95","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spring-boot-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring Boot - Write POST Methods - Learn Spring Boot<\/title>\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.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Boot - Write POST Methods - Learn Spring Boot\" \/>\n<meta property=\"og:description\" content=\"In this lesson we would write the post methods. This method would lets use insert new records. For example, create new user, new location and &hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn Spring Boot\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-07T12:51:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-07-26T08:13:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Write-the-POST-Methods.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"782\" \/>\n\t<meta property=\"og:image:height\" content=\"451\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"kindsonthegenius\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"kindsonthegenius\" \/>\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.kindsonthegenius.com\\\/spring-boot\\\/12-spring-boot-write-post-methods\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/12-spring-boot-write-post-methods\\\/\"},\"author\":{\"name\":\"kindsonthegenius\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#\\\/schema\\\/person\\\/7f8fc5792578d2ff54003fcebe6c46b5\"},\"headline\":\"Spring Boot &#8211; Write POST Methods\",\"datePublished\":\"2019-03-07T12:51:44+00:00\",\"dateModified\":\"2020-07-26T08:13:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/12-spring-boot-write-post-methods\\\/\"},\"wordCount\":471,\"commentCount\":3,\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/12-spring-boot-write-post-methods\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2019\\\/03\\\/Write-the-POST-Methods.jpg\",\"articleSection\":[\"Spring Boot Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/12-spring-boot-write-post-methods\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/12-spring-boot-write-post-methods\\\/\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/12-spring-boot-write-post-methods\\\/\",\"name\":\"Spring Boot - Write POST Methods - Learn Spring Boot\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/12-spring-boot-write-post-methods\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/12-spring-boot-write-post-methods\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2019\\\/03\\\/Write-the-POST-Methods.jpg\",\"datePublished\":\"2019-03-07T12:51:44+00:00\",\"dateModified\":\"2020-07-26T08:13:13+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#\\\/schema\\\/person\\\/7f8fc5792578d2ff54003fcebe6c46b5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/12-spring-boot-write-post-methods\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/12-spring-boot-write-post-methods\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/12-spring-boot-write-post-methods\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2019\\\/03\\\/Write-the-POST-Methods.jpg\",\"contentUrl\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/wp-content\\\/uploads\\\/sites\\\/7\\\/2019\\\/03\\\/Write-the-POST-Methods.jpg\",\"width\":782,\"height\":451},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/12-spring-boot-write-post-methods\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Spring Boot &#8211; Write POST Methods\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#website\",\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/\",\"name\":\"Learn Spring Boot\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/#\\\/schema\\\/person\\\/7f8fc5792578d2ff54003fcebe6c46b5\",\"name\":\"kindsonthegenius\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g\",\"caption\":\"kindsonthegenius\"},\"url\":\"https:\\\/\\\/www.kindsonthegenius.com\\\/spring-boot\\\/author\\\/kindsonthegenius-3\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Boot - Write POST Methods - Learn Spring Boot","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.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/","og_locale":"en_US","og_type":"article","og_title":"Spring Boot - Write POST Methods - Learn Spring Boot","og_description":"In this lesson we would write the post methods. This method would lets use insert new records. For example, create new user, new location and &hellip;","og_url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/","og_site_name":"Learn Spring Boot","article_published_time":"2019-03-07T12:51:44+00:00","article_modified_time":"2020-07-26T08:13:13+00:00","og_image":[{"width":782,"height":451,"url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Write-the-POST-Methods.jpg","type":"image\/jpeg"}],"author":"kindsonthegenius","twitter_card":"summary_large_image","twitter_misc":{"Written by":"kindsonthegenius","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/#article","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/"},"author":{"name":"kindsonthegenius","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#\/schema\/person\/7f8fc5792578d2ff54003fcebe6c46b5"},"headline":"Spring Boot &#8211; Write POST Methods","datePublished":"2019-03-07T12:51:44+00:00","dateModified":"2020-07-26T08:13:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/"},"wordCount":471,"commentCount":3,"image":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Write-the-POST-Methods.jpg","articleSection":["Spring Boot Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/","url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/","name":"Spring Boot - Write POST Methods - Learn Spring Boot","isPartOf":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/#primaryimage"},"image":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/#primaryimage"},"thumbnailUrl":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Write-the-POST-Methods.jpg","datePublished":"2019-03-07T12:51:44+00:00","dateModified":"2020-07-26T08:13:13+00:00","author":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#\/schema\/person\/7f8fc5792578d2ff54003fcebe6c46b5"},"breadcrumb":{"@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/#primaryimage","url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Write-the-POST-Methods.jpg","contentUrl":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-content\/uploads\/sites\/7\/2019\/03\/Write-the-POST-Methods.jpg","width":782,"height":451},{"@type":"BreadcrumbList","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/12-spring-boot-write-post-methods\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.kindsonthegenius.com\/spring-boot\/"},{"@type":"ListItem","position":2,"name":"Spring Boot &#8211; Write POST Methods"}]},{"@type":"WebSite","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#website","url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/","name":"Learn Spring Boot","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.kindsonthegenius.com\/spring-boot\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.kindsonthegenius.com\/spring-boot\/#\/schema\/person\/7f8fc5792578d2ff54003fcebe6c46b5","name":"kindsonthegenius","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b9d710de456c3d85e5614c3a6992fa3d527425e2ab32b8bd5d85bfbaa235004b?s=96&d=mm&r=g","caption":"kindsonthegenius"},"url":"https:\/\/www.kindsonthegenius.com\/spring-boot\/author\/kindsonthegenius-3\/"}]}},"_links":{"self":[{"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts\/95","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/comments?post=95"}],"version-history":[{"count":4,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts\/95\/revisions"}],"predecessor-version":[{"id":234,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/posts\/95\/revisions\/234"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/media\/104"}],"wp:attachment":[{"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/media?parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/categories?post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kindsonthegenius.com\/spring-boot\/wp-json\/wp\/v2\/tags?post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}