我想将以下(工作)curl片段转换为RestTemplate调用:
curl -i -X POST -d "email=first.last@example.com" https://app.example.com/hr/email
Run Code Online (Sandbox Code Playgroud)
如何正确传递电子邮件参数?以下代码导致404 Not Found响应:
String url = "https://app.example.com/hr/email";
Map<String, String> params = new HashMap<String, String>();
params.put("email", "first.last@example.com");
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> response = restTemplate.postForEntity( url, params, String.class );
Run Code Online (Sandbox Code Playgroud)
我试图在PostMan中制定正确的调用,我可以通过将body参数指定为正文中的"form-data"参数来使其正常工作.在RestTemplate中实现此功能的正确方法是什么?
例如,在HTTP中,您发送请求并接收响应; 是否有一个描述请求 - 响应对的名词?
我想到了"对话"或"对话",但是这些意味着多个请求 - 响应对,而我正在寻找一个指示一个单词的单词.
问的原因是我需要命名一个封装两者细节的对象,RequestResponse看起来相当蹩脚.
我在rfc 2616中找不到一件事,那就是请求/响应对的"规范"名称.有这样的事吗?
4.1 Message Types
HTTP messages consist of requests from client to server and responses
from server to client.
HTTP-message = Request | Response ; HTTP/1.1 messages
以此为模板,你会在下面的句子中加入哪个单词?
A single complete HTTP ... consists of one HTTP Request and one HTTP Response
HTTP-... = Request Response
往返?周期?
我正在使用 spring-mvc 构建 REST 服务,我现在正在寻找一种从 Spring MVC 控制器内部将 HTTP 请求代理到外部 REST 服务的方法。
我正在获取 HttpServletRequest 对象,并希望代理它进行尽可能少的更改。对我来说最重要的是保持传入请求的所有标头和属性原样。
@RequestMapping('/gateway/**')
def proxy(HttpServletRequest httpRequest) {
...
}
Run Code Online (Sandbox Code Playgroud)
我只是尝试使用 RestTemplate 向外部资源发送另一个 HTTP 请求,但我没有找到复制请求属性的方法(这对我来说非常重要)。
提前致谢!