我的休息api使用带有2个对象参数的POST请求:自定义类型和长
我可以将一个参数链接到body,如下所示:
private void createCaseParticipant(long caseId, CaseParticipantDTO caseParticipantDTO)
{
HttpHeaders headers = new HttpHeaders();
headers.add(AUTHORIZATION_HEADER_NAME, BASIC_AUTHORIZATION_HEADER_PREFIX + cmsRestApiCreds);
HttpEntity<CaseParticipantDTO> postRequest = new HttpEntity<CaseParticipantDTO>(caseParticipantDTO, headers);
}
如何在我的请求中添加第二个参数? 谢谢
答案 0 :(得分:1)
你只需将它添加到HttpHeadersobjects就像这样:
private void createCaseParticipant(long caseId, CaseParticipantDTO caseParticipantDTO)
{
HttpHeaders headers = new HttpHeaders();
headers.add(AUTHORIZATION_HEADER_NAME, BASIC_AUTHORIZATION_HEADER_PREFIX + cmsRestApiCreds);
headers.add("caseId",caseId.toString());
headers.add("caseParticipantDTO", caseParticipantDTO.toString());
HttpEntity<CaseParticipantDTO> postRequest = new HttpEntity<CaseParticipantDTO>(caseParticipantDTO, headers);
}