Skip to main content
The First Step
June 19, 2019
Question

Can't send SMS with spaces

I can send SMS with no spaces, as soon as I try to make a full sentence or even one space, I receive the error message,

{

"errorCode" : "InvalidJson",

"message" : "Invalid json in section [text]",

"errors" : [ {

"errorCode" : "CMN-131",

"message" : "Invalid json in section [text]",

"section" : "text"

} ],

"section" : "text"

}


Here is my curl post.


"-X POST

-H "accept: application/json"

-H "content-type: application/json"

-H "authorization: Bearer "& $token &" "


--data {"from":{"phoneNumber":"xxxxxxxxxx"},"to":[{"phoneNumber":"xxxxxxxxxx"}],"text":"test test"}"

Any help would be appreciated.

    5 replies

    PhongVu
    Community Manager
    Community Manager
    June 19, 2019

    Not sure why your system does not work. This works fine for me

    curl -XPOST https://platform.devtest.ringcentral.com/restapi/v1.0/account/[accountid]/extension/[extensionId]/sms -H 'accept: application/json' -H 'content-type: application/json' -H 'authorization: Bearer valid-access-token' --data '{"from":{"phoneNumber":"xxxxxxxxxx"},"to":[{"phoneNumber":"xxxxxxxxxx"}],"text":"test test and test again"}'

    Can you try with "test%20test"

    The First Step
    June 20, 2019

    I am using this in Filemaker if that helps at all?

    The First Step
    June 22, 2019

    This is something wired ... I never faced this issue.. Just see I am getting the response perfectly

    Make sure you using correct Json POST request as below format and structure:

    {"from":{"phoneNumber":"your phone number"},"to":[{"phoneNumber":"Your number to send"},{"phoneNumber":"Your number to send"}],"text":"Test message with space"} 
    The First Step
    July 31, 2019

    Please check the phone numbers as well, it needs to be in E.164 format - Also, what is the error message you are facing? Can you elaborate?

    The First Step
    December 17, 2021

    FileMaker encodes the data in a weird way...To get spaces in the text body to produce valid code, the --data must be used from a variable:
    Set Variable $data ; "{"from":{"phoneNumber":"" & $from & ""},"text":"" & $message & "","to":[{"phoneNumber":"" & $to & ""}]}"

    then the cURL must reference "-d @$data" as in:

    "--request POST" & ¶ &
    "--header "Accept: application/json"" & ¶ &
    "--header "authorization: Bearer " & $token & """ & ¶ &
    "--header "content-type: application/json"" & ¶ &
    "-d @$data"