繁体   English   中英

使用 resttemplate Exchange 在 POST 请求正文中发送参数和列表

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM