简体   繁体   English

rest api - 如何在rest api调用中发送邮递员的身体参数

[英]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.

相关问题 如何在 spring 中使用参数进行 Rest Api 调用 - How to make Rest Api call with parameters in spring 如何捕获其余api控制器上的文件以及使用Postman发送它的方法 - how to catch a file on the rest api controller and what method to send it with Postman 如何将时间和日期值从邮递员发送到我的 REST API - How to send Time and Date value from Postman to my REST API 如何通过邮递员调用REST API在Azure中创建索引? - How to call REST API through postman to create index in Azure? 如何使用邮递员调用REST API进行Azure文件存储? - How to call REST API for azure file storage using postman? 如何将请求正文中的列表值发送到 Rest Api - How to send List value in Request Body to Rest Api 如何使用邮递员休息客户端发送对象以调用REST服务 - how to send object using postman rest client to call REST service 如何在 Z03D476861AFD3841110F2CB80CCFA8 中请求 Rest API eclipse 服务? - How to request Rest API eclipse service in postman? 如何使用 java 将 1 到多个参数发送到 Rest Api - How to send 1 to many parameters to a Rest Api using java 如何使用邮递员休息客户端发送对象以调用REST服务,以便它将使用适当的方法参数命中以下给定的方法? - how to send object using postman rest client to call REST service so that it will hit the below given method with proper method parameters?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM