question

tweety5299 avatar image
tweety5299 asked tweety5299 commented

spring REST template to send fax with attachment

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

rest api
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

ak avatar image
ak answered tweety5299 commented
Hi,

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

3 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

tweety5299 avatar image tweety5299 commented ·
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 ! 


1 Like 1 ·
tweety5299 avatar image tweety5299 commented ·
Thank you for the pointer.
0 Likes 0 ·
ak avatar image ak commented ·
You are welcome Tweety. Did the sample code help ?
0 Likes 0 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys