-1

Hi I am able to call a rest api through postman . I have added the following in body part of postman. client_id - xxxx , client_secret - *** etc.

Now i want to make rest api call through java. How do i add these body parameters to request being created from java

simba
  • 277
  • 4
  • 19

1 Answers1

0

If you are using Spring, you can use the RestTemplate Spring REST client to make a call to an external API from Java.

Example:

 HttpHeaders headers = new HttpHeaders();
 headers.setContentType(MediaType.APPLICATION_JSON);
 HttpEntity<String> request = new HttpEntity<>(someDto, headers)
 restTemplate.postForEntity(postUrl, request, String.class);
Petar Bivolarski
  • 1,599
  • 10
  • 19