Created
September 4, 2021 00:47
-
-
Save edjeordjian/efd2eb32c166ba0f3ae6e41792d48da0 to your computer and use it in GitHub Desktop.
Quick way to send a post message in Spring Boot.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.http.converter.StringHttpMessageConverter; | |
import org.springframework.web.bind.annotation.PostMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
import org.springframework.web.client.RestTemplate; | |
public class SimplePostRequestInSpringBoot { | |
public void simplePost() { | |
RestTemplate client = new RestTemplate(); | |
client.getMessageConverters().add(new StringHttpMessageConverter()); | |
String url = "http://localhost:8080/your/endpoint/here"; | |
client.postForObject(url, new YourDTO(), YourDTO.class); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment