1
votes

My rest api uses POST request with 2 object parameters: custom type and long

enter image description here

I can link one parameter to body like this:

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

How can I add second parameter to my request? Thank you

1

1 Answers

2
votes

you can simply add it to the HttpHeadersobjects something like this :

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