Home > Back-end >  RestTemplate post request cannot transfer form - a great god guidance data parameters
RestTemplate post request cannot transfer form - a great god guidance data parameters

Time:10-04

 RestTemplate RestTemplate=new RestTemplate (); 

MultiValueMap The map=new LinkedMultiValueMap<> (16);
Map. The add (" cabinetUeSn cabinetSn);
The map. The add (" operate ", String. The valueOf (5));
Map. The add (" ueSn BT104802420RQZN190807001 ", "");
The map. The add (" id ", String. The valueOf (sequence. NextId ()));
//way to create a post request object
HttpHeaders headers=new HttpHeaders ();
Headers. SetContentType (MediaType. MULTIPART_FORM_DATA);
Headers. The add (" Authorization ", "Basic cm9reWluZm86RTEwQURD * * * * * * * * * * * * * * * * * * * * * * * *");
HttpEntity RequestEntity=new HttpEntity<> (map, headers);
String resultData=https://bbs.csdn.net/topics/restTemplate.postForEntity (OPERATE_EXCHANGE, requestEntity, String. The class). GetBody ();
{if (StringUtils. IsNotEmpty (resultData))
CabinetOperateResponse=JSONObject. ParseObject (resultData, cabinetOperateResponse. Class);
}
  • Related