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
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
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