question

dlavigna13863 avatar image
dlavigna13863 asked ·

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

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" : ""

}
General Topic
1 |1000 characters needed characters left characters exceeded

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 ·
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
3 comments
1 |1000 characters needed characters left characters exceeded

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

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);

}
0 Likes 0 ·
Hi, do you have a demo Fax page from Java?
0 Likes 0 ·
how to set the QueryParameters 

ResponseBody responseBody = (ResponseBody) restClient.post(

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

            qParam);
0 Likes 0 ·
Phong Vu avatar image
Phong Vu answered ·
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
1 |1000 characters needed characters left characters exceeded

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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