gpt4 book ai didi

java - 将多个对象链接到 HttpEntity

转载 作者:行者123 更新时间:2023-11-30 07:15:20 25 4
gpt4 key购买 nike

我的rest api使用带有2个对象参数的POST请求:自定义类型和long

enter image description here

我可以将一个参数链接到正文,如下所示:

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);
}

如何向我的请求添加第二个参数?谢谢

最佳答案

您可以简单地将其添加到 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);
}

关于java - 将多个对象链接到 HttpEntity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38505211/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com