question

IT Department avatar image
IT Department asked IT Department commented

Send High Volume got "CMN-101","message":"Parameter [from] value is invalid.

Hi there,

I'm using RingCentral SDK 2.4 to test the API to send High Volume SMS (HV SMS). My application has been approved and active on PROD environment.

I'm using the sample code as bellow:

    CreateSMSMessageBatchRequest parameters = new CreateSMSMessageBatchRequest();
    parameters.from = "+14082223XXX";
    parameters.text = "Hello Team, This is MOSO called High Volume APIs";
    String[] numbers = new String[] {"+14243325470", "+14243325455"};
    parameters.messages = new MessageCreateRequest[numbers.length];
    for (int i=0; i<numbers.length; i++) {
      MessageCreateRequest m = new MessageCreateRequest();
      m.to = new String[] {numbers[i]};
      parameters.messages[i] = m;
    }
    for (int i = 0; i < 2 ; i++ ) {
      MessageBatchInfo post = restClient.restapi().account().a2pSms().batches().post(parameters);
      System.out.println(post.from + " - " + post.id + " - " + post.creationTime +
              " - " + post.status + " - " + post.batchSize + " - " + post.processedCount);
    }


But i alway got this (404) error message:

status code: 400

Server: nginx
Date: Wed, 04 Jan 2023 10:18:32 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
RCRequestId: 23862f92-8c19-11ed-b66f-0050568ccada
X-Rate-Limit-Group: light
X-Rate-Limit-Limit: 50
X-Rate-Limit-Remaining: 49
X-Rate-Limit-Window: 60
RoutingKey: SJC01P17

{"errorCode":"CMN-101","message":"Parameter [from] value is invalid.","errors":[{"errorCode":"CMN-101","message":"Parameter [from] value is invalid."}]}

HTTP Request
============
HTTP POST https://platform.ringcentral.com/restapi/v1.0/account/~/a2p-sms/batches

Authorization: Bearer U0pDMDFQMTdQQVMwMHxBQURuU2lET2JsYTNhMDg2ejVLTmRfYl9jMS04ZjVQU3U5STR0THgwQTBQdlRZZ2hMTHhtRTREZF9idXktaElDQmI1ZkpmaFNfZnlUTENnUXBCSkdJMjZqYllibF9xdGJYZElybENlRjl6UlY5cmlsa2UtdnptTVhVwewewewewe4NmRZNm5FTHVuVXVsLUNWQlNvbFE3dVJJQ1VGRElDWkdzemhNWlRZZ0szTU1yZzRHY2VkNE9JN3hpS2lCaEo3OHgyaDNjZGpkSGlZRXxrMDZkNEF8bzVEN0hRZVF2aVg5NzBSSmFocWdxd3xBUXxBQXxBQUFBQU5FSC1hbw
X-User-Agent: RC-JAVA-SDK Java 1.8.0_221 Mac OS X


I'm pretty sure that the from number already correct.


I tried this website and my account work perfectly with this APIs:

https://www.sms-campaigns.com/standard

screenshot-2023-01-04-at-174745.png



high-volume sms
1 |3000

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

1 Answer

Phong Vu avatar image
Phong Vu answered IT Department commented

Your code is not correct. Try this!

CreateSMSMessageBatchRequest parameters = new CreateSMSMessageBatchRequest();
parameters.from = "+14082223XXX";
parameters.text = "Hello Team, This is MOSO called High Volume APIs";
        
String[] numbers = new String[] {"+14243325470", "+14243325455"};
MessageCreateRequest[] messages = new MessageCreateRequest[numbers.length];
for (int i=0; i<numbers.length; i++) {
    MessageCreateRequest m = new MessageCreateRequest();
    m.to = new String[] {numbers[i]};
    messages[i] = m;
}
parameters.messages = messages;
        
var resp = restClient.restapi().account().a2psms().batch().post(parameters);
System.out.println(convertObjToString(resp));
9 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.

IT Department avatar image IT Department commented ·

Thanks for your response but your code is not valid in RC JDK v2.2.0 anymore. The system show CE

<dependency>
  <groupId>com.ringcentral</groupId>
  <artifactId>ringcentral</artifactId>
  <version>2.2.0</version>
</dependency>


for (int i = 0; i < 2 ; i++ ) {
  MessageBatchInfo post = restClient.restapi().account().a2psms().batch().post(parameters);

  System.out.println(post.from + " - " + post.id + " - " + post.creationTime +
          " - " + post.status + " - " + post.batchSize + " - " + post.processedCount);
  Thread.sleep(15000);
}


The correct one should be

restClient.restapi().account().a2pSms().batches().post(parameters);

a2pSms instead of a2psms in v2.2.0


Can you let us know which version of the code should be work? I tried and the system still show invalid from number (+14082223XXX)

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ IT Department commented ·

I have no time to update the SDK but there could be some change in the params package. But your code to post in a for loop is incorrect. A2P SMS is sent in a batch and you don't send one by one because you already provide all the recipients in the "messages": [{"to":["recipient 1]}, {"to":["recipient 2]}, {"to":["recipient n]}]

However, having a closer look to your number and the screenshot. Your number 408 222 3xxx is not a HV SMS number. Therefore, you cannot use the A2P SMS API to send message. Use the /sms endpoint instead.

0 Likes 0 ·
IT Department avatar image IT Department Phong Vu ♦♦ commented ·

The loops just only for testing. I know exactly that A2psms API work that not cause my problem i'm facing

The number im using can send the HV SMS campaign in your site https://www.sms-campaigns.com/standard.

screenshot-2023-01-06-at-071051.png

Why you know which number is A2P SMS and which is not? How can we know that in our site?

My from number is: "from":"+14082223222"

If you don't have time to help, please assign someone to help us. Please. We are got stuck on this and could not continues in our site

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