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
Response: StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Connection: keep-alive RCRequestId: 56564a9c-9ec3-11ea-9c69-005056af5c03 RoutingKey: IAD01P13PAS06 X-Rate-Limit-Group: medi
Tags: rest api
May 27, 2020 at 3:16pm   •   2 replies  •  0 likes
PCIC Team

Here is the code you asked for in this issue.


public async Task<object> Read(FaxReadType faxReadType)
{
        object returnData = null;
        try
        {
            using (RestClient rc = new RestClient(RINGCENTRAL_CLIENTID
                                                , RINGCENTRAL_CLIENTSECRET
                                                , IS_PRODUCTION))
            {
                TokenInfo tokenInfo = await rc.Authorize(RINGCENTRAL_USERNAME
                                                        , RINGCENTRAL_EXTENSION
                                                        , RINGCENTRAL_PASSWORD);

                if (rc.token.access_token.Length > 0)
                {
                    switch (faxReadType)
                    {
                        case FaxReadType.ReadContent:
                            ReadMessageContentParameters read = new ReadMessageContentParameters
                            {
                                contentDisposition = "Attachment"
                            };

                            returnData = await rc.Restapi().Account().Extension()
                                            .MessageStore(messageId).Content(attachmentId).Get(read);
                            break;

                        case FaxReadType.ReadMessage:
                            returnData = await rc.Restapi().Account().Extension()
                                            .MessageStore(messageId).Get();
                            break;
                    }
                }
            }
        }
        catch (Exception ex)
        {
            //Log exception in DB
        }
        return returnData;
    }


2 Answers
answered on May 28, 2020 at 11:44am  

This is an example of how to read message store message's attachment.

private async Task read_message_store_by_id(string messageId)
{
  await rcsdk.Authorize(RINGCENTRAL_USERNAME, RINGCENTRAL_EXTENSION, RINGCENTRAL_PASSWORD);
  if (rcsdk.token.access_token.Length > 0)
  {
    var response = await rcsdk.Restapi().Account().Extension().MessageStore(messageId).Get()
    if (response.attachments != null)
    {
      var path = "fax_content/";
      System.IO.Directory.CreateDirectory(path);
      foreach (var attachment in response.attachments)
      {
        var fileName = response.attachments[0].id + "_fax_attachment";
        var fileNameExt = attachment.contentType.Split('/');
        fileName = String.Format("{0}.{1}", fileName, fileNameExt[1]
        Console.WriteLine(fileName);
        var start = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds();
        var res = await rcsdk.Restapi().Account().Extension().MessageStore(response.id.ToString()).Content(attachment.id.ToString()).Get();
        using (BinaryWriter writer = new BinaryWriter(System.IO.File.Open(path + fileName, FileMode.Create)))
        {
          writer.Write(res);
          writer.Flush();
          writer.Close();
        }
        Console.WriteLine("Done");
     }
   }
  }
}



 0
answered on May 27, 2020 at 4:44pm  

That is just a wrong way to read the attachment of a fax message. I don't know where you get the "messageId" from. Is you intention just to read the attachment and save to a local file?


 0



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