We are using NugetPackage 6.1.1 and getting "Parameter [to] value is invalid." when sending a fax.
The error message and examination of the code in the RingCentral.Net library shows that the request is being sent as formData with a request.json parameter and the CreateMessageRequest serialized as JSON.
Is this correct? Should the library be sending FormData with individual paramters?
RingCentral.RestException: 'Response:
StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
Date: Fri, 09 Feb 2024 21:38:57 GMT
Connection: keep-alive
RCRequestId: a11e264c-c793-11ee-a688-005056bbd8ff
RoutingKey: SJC11P01PAS01
X-Rate-Limit-Group: heavy
X-Rate-Limit-Limit: 10
X-Rate-Limit-Remaining: 9
X-Rate-Limit-Window: 60
CF-Cache-Status: DYNAMIC
Server: cloudflare
CF-RAY: 852f43222dcd6c20-DFW
Content-Type: application/json;charset=utf-8
Content-Length: 246
Content-Language: en-US
}
Content: {
"errorCode" : "InvalidParameter",
"message" : "Parameter [to] value is invalid.",
"errors" : [ {
"errorCode" : "CMN-101",
"message" : "Parameter [to] value is invalid.",
"parameterName" : "to"
} ],
"parameterName" : "to"
}
Request:
Method: POST, RequestUri: 'https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/fax', Version: 1.1, Content: System.Net.Http.MultipartFormDataContent, Headers:
{
X-User-Agent: Unknown/0.0.1 RingCentral.Net/6.1.1
Authorization: Bearer ***
Request-Context: appId=cid-v1:e4663832-4025-415d-9de8-032949192fbf
Request-Id: |2fb8e6b3fe3342300ee87c258eb31fc7.250cf52c456bb8fc.
traceparent: 00-2fb8e6b3fe3342300ee87c258eb31fc7-250cf52c456bb8fc-00
Content-Type: multipart/form-data; boundary="6891f609-723d-4277-8042-4621dbca7605"
Content-Length: 260466
}
Content: --6891f609-723d-4277-8042-4621dbca7605
Content-Type: application/json; charset=utf-8
Content-Disposition: form-data; name=request.json
{"faxResolution":"High","to":[{"phoneNumber":"+**********"}],"sendTime":"2/9/2024 2:06 PM"}
--6891f609-723d-4277-8042-4621dbca7605
Content-Type: application/pdf
Content-Disposition: form-data; name=attachments; filename=Negotiation_178370-ScaCoversheet.pdf; filename*=utf-8''Negotiation_178370-ScaCoversheet.pdf
%PDF-1.7
************************************
Check out this dev guide sample code. The bodyParams must be the CreateFaxMessageRequest object and the "to" is the FaxReceiver[].
That is exactly what we have used to create our fax request. Is there a specific format for the phone or "to" values as the examples don't show how those are formatted. We use the .Net SDK to create all of this, yet it does not work.
I can't find this object name "CreateMessageRequest" from the error trace you posted so I don't know where did you see it. Did you create the request using that object?
I just sent a test fax again using my code and it worked well.
/* Send a high resolution fax message to a recipient number */ static private async Task send_fax() { var bodyParams = new CreateFaxMessageRequest(); bodyParams.to = new FaxReceiver[] new FaxReceiver { phoneNumber = "+1209252XXXX" } }; bodyParams.faxResolution = "High"; bodyParams.coverPageText = "This is a demo Fax page from C#"; var attachment = new Attachment { filename = "test.jpg", contentType = "image/jpeg", content = System.IO.File.ReadAllBytes("test.jpg") }; var attachments = new Attachment[] { attachment }; bodyParams.attachments = attachments; var resp = await restClient.Restapi().Account().Extension().Fax().Post(bodyParams); Console.WriteLine("Fax sent. Message id: " + resp.id); await check_fax_message_status(resp.id.ToString()); } /* Check the sending message status until it's no longer in the queued status */ static private async Task check_fax_message_status(string messageId) { try { var resp = await restClient.Restapi().Account().Extension().MessageStore(messageId).Get(); Console.WriteLine("Message status: " + resp.messageStatus); if (resp.messageStatus == "Queued") { Thread.Sleep(10000); await check_fax_message_status(resp.id.ToString()); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
If everything is correct in your code, maybe it's truly the to fax number is invalid. You can submit a dev support ticket to get help.
Ok, let me stub your test code into our API and see if it sends. You don't see the Type CreateMessageRequest because this is an HTTP response, so it doesn't know about the type. But when building the request to send, we are using the CreateMessageRequest from the RingCentral SDK.
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