Can I send text message with new line character using Ringcntral Apis? if i can send then in which way please explain.

  • 1
  • Question
  • Updated 2 years ago
  • (Edited)
Can I send text message with new line character using Ringcntral Apis? if i can send then in which way please exaplin.
currently i am trying to send SMS using RingCentral Apis but it gives me error like "Parameter [text] value is invalid".

Following is my values which i am passing into api in UTF-8 Encode.
"%7B%22to%22=%5B%7B%22phoneNumber%22%3A+%2214133767135%22%7D%5D%2C%22from%22%3A+%7B%22phoneNumber%22%3A+%22%2B13464448263%22%7D%2C%22text%22%3A+%22What+is+your+ETA%3F%0D%0A+What+is+your+location%3F+What+time+you+started+loading%3F+What+time+you+finished+loading%3F+Are+you+loaded+%3F%22%7D"

Following is my values which i am passing into api.
"{"to"=[{"phoneNumber": "14133767135"}],"from": {"phoneNumber": "+13464448263"},"text": "What is your ETA?
 What is your location? What time you started loading? What time you finished loading? Are you loaded ?"}"

Can you please help me to do same like above?

Thanks
Photo of Eddie

Eddie

  • 94 Points 75 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Benjamin Dean

Benjamin Dean, Alum

  • 8,622 Points 5k badge 2x thumb
Per our API Developer Guide specification, the `text` property of the POST for SMS must has these characteristics:

Text of a message. Max length is 1000 symbols (2-byte UTF-16 encoded). If a character is encoded in 4 bytes in UTF-16 it is treated as 2 characters, thus restricting the maximum message length to 500 symbols

Here is a handy article on StackOverflow explaining the differences between UTF-8 and UTF-16: http://stackoverflow.com/questions/496321/utf8-utf16-and-utf32

Of course, just using normal Unix newline characters I was able to send myself an SMS with the expected results. Here is the body I used as the `text` property in the HTTP POST to /restapi/v1.0/account/~/extension/~/sms:

{"from":{"phoneNumber":"16503514622"},"to":[{"phoneNumber":"13176009731"}],"text":"Hello Ben,\n\n How are you?"}

Here is a screenshot (the bottom message is the above body) The message at 13:13, with the double newlines, was me testing and I used windows newline \r\n and Unix newline \n\n):

(Edited)