[英]rest api - how to send body parameters of postman in rest api call
Hi I am able to call a rest api through postman .嗨,我可以通过邮递员调用休息 api。 I have added the following in body part of postman.
我在邮递员的身体部分添加了以下内容。 client_id - xxxx , client_secret - *** etc.
client_id - xxxx ,client_secret - *** 等。
Now i want to make rest api call through java.现在我想通过java进行rest api调用。 How do i add these body parameters to request being created from java
我如何将这些正文参数添加到从 java 创建的请求中
If you are using Spring, you can use the RestTemplate Spring REST client to make a call to an external API from Java.如果您使用的是 Spring,则可以使用RestTemplate Spring REST 客户端从 Java 调用外部 API。
Example:例子:
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<String> request = new HttpEntity<>(someDto, headers)
restTemplate.postForEntity(postUrl, request, String.class);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.