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
C# Sending Fax - Parameter [to] value is invalid.
Tags: fax, sdk
Feb 9, 2024 at 1:50pm   •   1 replies  •  0 likes
Occunet AppDev

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

************************************

1 Answer
answered on Feb 12, 2024 at 6:08am  

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.


 0
answered on Feb 9, 2024 at 3:54pm  

Check out this dev guide sample code. The bodyParams must be the CreateFaxMessageRequest object and the "to" is the FaxReceiver[].


 0
on Feb 12, 2024 at 6:09am   •  0 likes

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.

on Feb 12, 2024 at 7:18am   •  0 likes

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.

on Feb 15, 2024 at 7:18am   •  0 likes

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

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