News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
How to attach PDF to a fax message?
Tags: fax
Aug 19, 2015 at 7:15am   •   4 replies  •  0 likes
kevin-truong

I am trying to attach a pdf to a fax that i am sending using code below


HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(url);

Stream rs = wr.GetRequestStream();

StreamReader sr = new StreamReader(filepath);

byte[] fileStream = ReadFully(sr.BaseStream);

rs.Write(fileStream, 0, fileStream.Length);

sr.Close();


public static byte[] ReadFully(Stream input)

{


byte[] buffer = new byte[20 * 1024];

using (MemoryStream ms = new MemoryStream())

{


if (input != null)

{


int read;

while ((read = input.Read(buffer, 0, buffer.Length)) > 0)

{


ms.Write(buffer, 0, read);

}

}

return ms.ToArray();

}

}


I get back the response that Fax was Queued, but when I receive fax it is only default cover page. This mean the binary data was not attached. What am I missing?

4 Answers
answered on Jun 29, 2019 at 12:49pm  

For those who want to use fax API, the fax api support attachments as data which means no data will be passed in body, instead all the data including files and plain text will be pass as an attachment in the api

  1. Content-Type: multipart/mixed

The API allows sending a fax message with a multipart request, incorporating two or more parts.

ref: https://developers.ringcentral.com/api-reference#

other examples: https://github.com/grokify/go-ringcentral/tree/master/examples


 0
answered on Aug 19, 2015 at 4:35pm  
That error typically indicates that the username / extension / password credentials supplied are incorrect. You should make sure that the credentials you are using are associated with your Sandbox Account.

The Sandbox Account Main Company Number for this account is located in your Developer Portal account (https://developers.ringcentral.com) under Sandbox Accounts. By default, the admin extension, 101, is configured with a password that is emailed to you.

You can test that phone number by logging into the Sandbox Online Account Portal here: https://service.devtest.ringcentral.com.

Let us know if that works.

 0
answered on Aug 19, 2015 at 3:46pm  
Thanks John for your quick reply. Good to hear about .Net SDK, I am looking into it now as my application is configured for Sandbox so I am using  
https://platform.devtest.ringcentral.com  
as apiEndPoint and when trying to Authenticate I am getting response

{
  "error" : "invalid_grant",
  "error_description" : "Invalid resource owner credentials."
}

Do I have to give permission for SDK to connect to my application somewhere?

 0
answered on Aug 19, 2015 at 9:55am  
To send a fax you'll need to create a multipart/mixed request and add each PDF as an attachment. You can either send the raw bytes or base 64 encode the file.

The easiest way to do this with C# is to use our new (alpha) SDK which is available on Nuget and GitHub:
You can get the package from Nuget and follow the fax instructions under "Send Fax" on the GitHub link.

There are example request bodies on the community Ruby SDK documentation here if you're interested in what the raw requests look like:

 1



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us