![](/img/trans.png)
[英]how to send the data in request body as json to resttemplate.exchange
[英]Send parameters and a list in body of POST request WIth resttemplate Exchange
嗨,我必须使用这些参数发送带有 resttemplate.exchange 的 POST 请求
{
"tipoPortafoglio": "string",
"allegatiPratica": [
{
"fileName": "string",
"body": "string",
"mimeType": "string"
}
]
}
我有一个映射的 class 这个叫做
Public class CreateRichiesta {
String tipoPortafoglio
Allegato allegatiPratica //<===== Custom type defined as JSON
//Getter and setters
由于 customtype 事实,我无法使用 HashMap 将实体传递给 RestTemplate.Exchange
Map<String,String> input = new HashMap<>();
input.put("tipoPortafoglio", request.getTipoPortafoglio());
input.put("allegatiPratica", request.getAllegatiPratica()));
getAllegatiPratica 不是字符串类型而是 Allegato 类型
我该怎么办?谢谢大家
HttpEntity<CreateRichiesta> request = new HttpEntity<>(new CreateRichiesta());
ResponseEntity<CreateRichiestaResponse> responseEntityObj = restTemplate
.exchange(resourceUrl, HttpMethod.POST, request, CreateRichiestaResponse.class);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.