question

arpit-patel11485 avatar image
arpit-patel11485 asked arpit-patel11485 commented

Internal Server Error - Sending Multiple Fax C# .NET

Not able to send the multiple fax using following code:


Getting this Error,

{


"message" : "Internal Server Error. Consult RC Support.",

"eventId" : "0eac3cde-a7b6-11e8-a382-005056bb26b9"


}


---------------------------------------------------------------------------------------

We have used following code.






Any help will be appreciated. Thank you!



errors
1 |3000

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

John Wang avatar image
John Wang Deactivated answered
Can you make any other API calls successful? For example, calling the extension info endpoint.

I'm wondering if this is an issue with the PDF file itself.

Can you try the example PDF file here (click the "Download"):

https://github.com/grokify/go-ringcentral/blob/master/examples/fax_send/test_file.pdf

If that works, can you provide an example PDF that is failing. If so, join our Glip team here:

https://glipped.herokuapp.com/
1 |3000

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

anton-nikitin avatar image
anton-nikitin answered arpit-patel11485 commented
Arpit, I have found your request in server logs and sent it to Dev Team for investigation. Stay tuned.
6 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.

arpit-patel11485 avatar image arpit-patel11485 commented ·
Thank you Nikitin !
0 Likes 0 ·
arpit-patel11485 avatar image arpit-patel11485 commented ·
Hii Nikitin,

Do we have any update on this Internal Server Error??
0 Likes 0 ·
anton-nikitin avatar image anton-nikitin commented ·
Arpit, we cannot reproduce it. Apparently the HTTP request body you are sending is malformed. Can you trace HTTP request so we can see the entire body as it is sent to us? It would help a lot.
0 Likes 0 ·
arpit-patel11485 avatar image arpit-patel11485 commented ·
There you go,


class Program
    {
        static void Main(string[] args)
        {
            GetRingCentralAPIToken();
        }
        public static void GetRingCentralAPIToken()
        {
            string resultToken = string.Empty;
            var client = new RestClient(" https://platform.devtest.ringcentral.com/restapi/oauth/token");
            var request = new RestRequest(Method.POST);
            request.AddHeader("postman-token", "0488f4ed-13da-25d3-9f7f-d2243be3089b");
            request.AddHeader("cache-control", "no-cache");
            request.AddHeader("content-type", "application/x-www-form-urlencoded");
            request.AddHeader("accept", "application/json");
            request.AddHeader("authorization", "Basic bEZvRU5BQVFSMW1RT2RtZWpYb2xvZzpNQmxKLWl5RFNIdUIxRE5vVnZpRXpnU1RncFNwdHVSdWFBUWRpdWpqQzFBUQ==");
            request.AddParameter("application/x-www-form-urlencoded", "grant_type=password&username=16167946751&extension=101&password=*****", ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);
            string response_code = response.Content.ToString();
            var details = JObject.Parse(response.Content);
            resultToken = details["access_token"].ToString();
            PostFax("12052089553", resultToken, 1);
        }

        public static void PostFax(string getFaxNumber, string getToken, int transactionID)
        {

            string getDate = DateTime.UtcNow.ToString("o");
            var client = new RestClient(" https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/fax");
            var request = new RestRequest(Method.POST);
            request.AddHeader("postman-token", "8ca9f9bc-82de-60ef-ffb1-98ac03e017ce");
            request.AddHeader("cache-control", "no-cache");
            request.AddHeader("authorization", "bearer " + getToken);


            var pdfFile = File.ReadAllBytes("c:\\Testing PFD.pdf");

            request.AddHeader("content-type", "multipart/mixed; boundary=Boundary_1_14413901_1361871080888");
            request.AddParameter("multipart/mixed; boundary=Boundary_1_14413901_1361871080888", "--Boundary_1_14413901_1361871080888\r\nContent-Type: application/json\r\n\r\n{\"to\":[{\"phoneNumber\":\"" + getFaxNumber + "\"}],\r\n \"faxResolution\":\"High\",\r\n \"sendTime\":\"" + getDate + "\"}\r\n\r\n--Boundary_1_14413901_1361871080888\r\nContent-Disposition: form-data; name=\"attachment\"; filename=\"Testing PFD.pdf\"\r\nContent-Transfer-Encoding: " + pdfFile + "\r\nContent-Type: application/pdf\r\n\r\n\r\n--Boundary_1_14413901_1361871080888--\r\n", ParameterType.RequestBody);



            IRestResponse response = client.Execute(request);
            string response_code = response.Content.ToString();
            var details = JObject.Parse(response.Content);

        }
0 Likes 0 ·
anton-nikitin avatar image anton-nikitin commented ·
I think you can't get correct multipart/mixed body with this code. I recommend you to use multipart/form-data as described here in Pattern #3 :  https://developer.ringcentral.com/api-docs/latest/index.html#!#RefCreateFaxMessage to form request body like this:

POST /restapi/v1.0/account/691748004/extension/691748004/fax HTTP/1.1 Content-Type: multipart/form-data; boundary=Boundary_14_2952358_1361963763144  --Boundary_14_2952358_1361963763144 Content-Disposition: form-data; name="coverPageText" Content-Transfer-Encoding: 8bit Content-Type: text/plain   --Boundary_14_2952358_1361963763144 Content-Disposition: form-data; name="coverIndex" Content-Transfer-Encoding: 8bit Content-Type: text/plain  2 --Boundary_14_2952358_1361963763144 Content-Disposition: form-data; name="faxResolution" Content-Transfer-Encoding: 8bit Content-Type: text/plain  High --Boundary_14_2952358_1361963763144 Content-Disposition: form-data; name="sendTime" Content-Transfer-Encoding: 8bit Content-Type: text/plain  2030-03-19T08:00:00.000Z --Boundary_14_2952358_1361963763144 Content-Disposition: form-data; name="isoCode" Content-Transfer-Encoding: 8bit Content-Type: text/plain  GB --Boundary_14_2952358_1361963763144 Content-Disposition: form-data; name="to" Content-Transfer-Encoding: 8bit Content-Type: text/plain  +18774880001 --Boundary_14_2952358_1361963763144 Content-Disposition: form-data; name="to" Content-Transfer-Encoding: 8bit Content-Type: text/plain  +18004778345 --Boundary_14_2952358_1361963763144 Content-Disposition: form-data; name="attachment" Content-Transfer-Encoding: binary Content-Type: text/plain  attachment1  
--Boundary_14_2952358_1361963763144--

You should use RestRequest.AddFile to add your file as attachment as described here:  https://blog.tyrsius.com/restsharp-file-upload/

I am not C# expert so it is just my guess. 
 
0 Likes 0 ·
Show more comments
Tyler Liu avatar image
Tyler Liu answered Tyler Liu commented
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.

arpit-patel11485 avatar image arpit-patel11485 commented ·
I think this should work out . . .
0 Likes 0 ·
Tyler Liu avatar image Tyler Liu ♦ commented ·
Let me know if it doesn't work. I am always ready to help.
0 Likes 0 ·
arpit-patel11485 avatar image
arpit-patel11485 answered
We are still working on it: hopefully be able to figured this one out.
1 |3000

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

venkatesa-prasanna11530 avatar image
venkatesa-prasanna11530 answered arpit-patel11485 commented
Still we are having a issue.
Because we are having Visual Studio 2015 and Framework 4 used in our application.

1. We tried to install Ringcentral.Client from Nuget, we received the below message.

"Severity Code Description Project File Line Suppression State
Error  Could not install package 'Flurl.Http 2.1.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.  "

Please find attachment.



2. Also We have tried to install RingCentralSDK from Nuget and it is installed successfully. But After installed we tried to build our application, it is showing the following error.

Please find attachment.


So I request you that please provide us the source code which is support for .net framework 4.

We just wanted to use Fax API only to send multiple attachment and retrieve response only.

Thanks for your help.
6 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.

arpit-patel11485 avatar image arpit-patel11485 commented ·
Thank you: issue got resolved.
1 Like 1 ·
Tyler Liu avatar image Tyler Liu ♦ commented ·
Could you please upgrade to newer version of .net?

https://blogs.msdn.microsoft.com/dotnet/2015/12/09/support-ending-for-the-net-framework-4-4-5-and-4-...

.Net 4 is an very ancient version and Microsoft stopped supporting it in 2015. Lots of libraries from NuGet also don't support it.
0 Likes 0 ·
arpit-patel11485 avatar image arpit-patel11485 commented ·
Yes, you are right . . .

Upgrading the .Net Framework is a huge task for us as our application is quite big.
But is there any other way we can use FAX APIs in our application without using RingCentral.Client SDK ??

Please look at the problem of main thread: it is a Internal Server Error . . .
We just trying to resolve that one only.

** only fax api we wants to use in out application nothing else

Your response will be appreciated.

Thank you!
0 Likes 0 ·
Tyler Liu avatar image Tyler Liu ♦ commented ·
Actually there is an easy workaround. It is possible to send fax via curl:  https://medium.com/ringcentral-developers/use-curl-to-access-ringcentral-platform-api-d4710fe68fa4


curl is just a command line utility which has windows version:  https://curl.haxx.se/windows/


You can use C# to invoke curl:  https://stackoverflow.com/questions/1469764/run-command-prompt-commands


Please let me know whether the workaround above works for you.
0 Likes 0 ·
Tyler Liu avatar image Tyler Liu ♦ commented ·
Or you can use this SDK  https://github.com/ringcentral/ringcentral-csharp

It is deprecated. But it might be the only one which supports .NET 4.0

Fax sending sample:  https://github.com/ringcentral/ringcentral-csharp/blob/master/RingCentral.Test.Real/MessageTest.cs#L...
0 Likes 0 ·
Show more comments

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