Get an InvalidParameter error when trying to send a fax through API

  • 1
  • Problem
  • Updated 2 months ago

using this API

restClient.post(
    restClient.restApi("v1.0").account("~").extension("~").fax().endpoint(), 

    qParam);


with Query parameters

QueryParameter[] qParam = new QueryParameter[3];

            QueryParameter p0 = new QueryParameter("attachment", "");

            QueryParameter p1 = new QueryParameter("faxResolution", "High");

QueryParameter p2 = new QueryParameter("to", "+14694804418");

            qParam[0] = p0;

            qParam[1] = p1; 

            qParam[2] = p2; 

The error message is:
com.ringcentral.RestException: HTTP status code: 400

{

  "errorCode" : "InvalidParameter",

  "message" : "Parameter [] value is invalid",

  "errors" : [ {

    "errorCode" : "CMN-101",

    "message" : "Parameter [] value is invalid",

    "parameterName" : ""

  } ],

  "parameterName" : ""

}
Photo of MobiMed - API Test

MobiMed - API Test

  • 100 Points 100 badge 2x thumb

Posted 2 months ago

  • 1
Photo of Phong Vu

Phong Vu, Devangelist

  • 4,966 Points 4k badge 2x thumb
Hi, 

Here is snippet code to send fax.

var attachment = new Attachment { fileName = "test.jpg", contentType = "image/jpeg", bytes = System.IO.File.ReadAllBytes("test.jpg") };
var attachments = new Attachment[] { attachment };
var body = new {
               to = new CallerInfo[] { new CallerInfo { phoneNumber = RECIPIENT } },
               faxResolution = "High",
               coverPageText = "This is a demo Fax page from C Sharp"
               };
var resp = await rc.Restapi().Account().Extension().Fax().Post(body, attachments); 

Hope this helps!
+ Phong
Photo of MobiMed - API Test

MobiMed - API Test

  • 100 Points 100 badge 2x thumb

this is the exact code we're using. Kindly help me where things are going wrong


@RequestMapping(value = "sendFax", method = RequestMethod.POST)

@ResponseBody

public Response updateShoppingCart()

        throws InvalidRequestException, ResourceMissingException, IOException, RestException, FileUploadException {

        RestClient restClient = new RestClient(String clientId, String clientSecret, String server); //

        restClient.authorize("", "101", "");

        

String endpoint = restClient.restApi("v1.0").account("~").extension("~").fax().endpoint();

QueryParameter[] qParam = new QueryParameter[3];

        QueryParameter p0 = new QueryParameter("attachment", "");

        QueryParameter p1 = new QueryParameter("faxResolution", "High");

// We can use any fax number we want here, BUT we need to use the "+1" + 10-digit format

QueryParameter p2 = new QueryParameter("to", "");

        qParam[0] = p0;

        qParam[1] = p1; 

        qParam[2] = p2; 

        

        

ResponseBody responseBody = (ResponseBody) restClient.post(

            restClient.restApi("v1.0").account("~").extension("~").fax().endpoint(),

            qParam);

        return new Response(Status.Success);

}
Photo of MobiMed - API Test

MobiMed - API Test

  • 100 Points 100 badge 2x thumb
Hi, do you have a demo Fax page from Java?
Photo of MobiMed - API Test

MobiMed - API Test

  • 100 Points 100 badge 2x thumb
how to set the QueryParameters 

ResponseBody responseBody = (ResponseBody) restClient.post(

            restClient.restApi("v1.0").account("~").extension("~").fax().endpoint(),

            qParam);
Photo of Phong Vu

Phong Vu, Devangelist

  • 4,966 Points 4k badge 2x thumb
Sorry for misunderstood. I just quick looked at your code and thought that it was C#. 

Here is the example to send a Fax message using the Java SDK.

https://github.com/ringcentral/ringcentral-java/blob/master/src/test/java/com/ringcentral/FaxTest.ja...

+ Phong