question

PCIC Team avatar image
PCIC Team asked Phong Vu commented

Response: StatusCode: 404, ReasonPhrase: 'Not Found'

I was trying to read a fax and the following error was thrown "Response: StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Connection: keep-alive RCRequestId: a02bf940-ea3d-11e9-9b97-005056afc229 RoutingKey: SJC01P13PAS07 X-Rate-Limit-Group: medi "


FaxResponse response = null;

try
{
    using (RestClient rc = new RestClient(RINGCENTRAL_CLIENTID
                                        , RINGCENTRAL_CLIENTSECRET
                                        , IS_PRODUCTION))
    {
        TokenInfo token = await rc.Authorize(RINGCENTRAL_USERNAME
                                            , RINGCENTRAL_EXTENSION
                                            , RINGCENTRAL_PASSWORD);
        if (rc.token.access_token.Length > 0)
        {
            CreateFaxMessageRequest request = new CreateFaxMessageRequest
            {
                attachments = uploadedFiles.ToArray(),

                faxResolution = "High",

                to = new MessageStoreCallerInfoRequest[]
                {
                    new MessageStoreCallerInfoRequest { phoneNumber = toPhoneNumber }
                }
            };

            response = await rc.Restapi().Account().Extension().Fax().Post(request);

            return response;
        }
    }
}
catch (Exception ex)
{
    ins_error_log log = new ins_error_log();
    log.runSP(ex, false);
}

return response;


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.

Phong Vu avatar image
Phong Vu answered Phong Vu edited

You did not show the content within the uploadedFiles.ToArray() so I don't know how the attachments were added. Can you show the details or try this instead.

var requestParams = new CreateFaxMessageRequest();
var attachment = new Attachment { fileName = "test.jpg", contentType = "image/jpeg", bytes = System.IO.File.ReadAllBytes("test.jpg") };
var attachments = new Attachment[] { attachment };
requestParams.attachments = attachments;
requestParams.to = new MessageStoreCallerInfoRequest[] { new MessageStoreCallerInfo Request { phoneNumber = RECIPIENT } };
requestParams.faxResolution = "High";
requestParams.coverPageText = "This is a demo Fax page from C#";

var resp = await rc.Restapi().Account().Extension().Fax().Post(requestParams);
Console.WriteLine("Fax sent. Message status: " + resp.messageStatus); 


1 |3000

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

PCIC Team avatar image
PCIC Team answered Phong Vu commented

The files supported are jpg, jpeg, png, bmp, pdf, docx, xlsx and doc

attachments = uploadedFiles.ToArray()

In this case the variable "uploadedFiles" is of the type List<Attachment>. It is being converted into an Array, to support assignment to CreateFaxMessageRequest.attachments. I would like to know, why there is an error in production and I was not facing this during my sandbox testing.

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

PCIC Team avatar image PCIC Team commented ·

Any answer would be greatly appreciated?

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ commented ·

You should have mentioned in your first post about the fact that your code works on sandbox but failed in production. Otherwise, we just waste our time to go back and forth.

I am so sure that the attachment is not found but not sure how. I just saw your new question so I will follow up with you there.

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