spring REST template to send fax with attachment

  • 1
  • Question
  • Updated 2 years ago
Hi, 

Please find below the REST call to the "send fax" api. 
Though the fax is being sent, the attachment is not sent.

Can you please help if the request is missing some entity?

byte[] attachment = getBVendorRenewalLetter();
MultiValueMap<String,Object> bodyMap = new LinkedMultiValueMap<String,Object>();
bodyMap.add("file", attachment);
bodyMap.add("to", "test phone number");
bodyMap.add("Authorization", accessToken);

HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setContentDispositionFormData("content", "testFile.pdf");
headers.add("to", "test phone number");
headers.add("Authorization", accessToken);

HttpEntity<Object> requestEntity = new HttpEntity<Object>(bodyMap, headers);

ResponseEntity<RingCentralResponseDTO> response = restTemplate.exchange("https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/fax";, HttpMethod.POST, requestEntity, RingCentralResponseDTO.class);

Thank You very much
Photo of Tweety

Tweety

  • 110 Points 100 badge 2x thumb

Posted 2 years ago

  • 1
Photo of AK

AK, Official Rep

  • 4,402 Points 4k badge 2x thumb
Hi,

Please refer to the below sample in Java to send Fax:
https://github.com/vyshakhbabji/ringcentral-java/blob/master/src/utils/SendFax.java
Photo of Tweety

Tweety

  • 110 Points 100 badge 2x thumb
Thank you for the pointer.
Photo of AK

AK, Official Rep

  • 4,402 Points 4k badge 2x thumb
You are welcome Tweety. Did the sample code help?
Photo of Tweety

Tweety

  • 110 Points 100 badge 2x thumb
Yes AK. It did. Thank you very much once again. I used the sample code to use the okHttp Client to make the REST call and it works great !