question

ken-nye6499 avatar image
ken-nye6499 asked ken-nye6499 commented

getting error 415 Unsupported Media Type when sending SMS with sandbox app

Im getting error 415 Unsupported Media Type when sending SMS with sandbox app

APP ID VRbX8zVSRVeOvf0SoKM_1Q

I know my credentials are correct because I can 'GET' the messages I sent using the "try it out"
this is the body of the Json request

{
  "to": [{"phoneNumber": "+15555552586"}],
  "from": {"phoneNumber": "+15555552434"},
  "text": "The ARG is blank"
}

I am using the correct number and extension.
here is the header of the last request

{
  Server: nginx
  Date: Mon, 17 Jan 2022 02:21:20 GMT
  Connection: keep-alive
  RCRequestId: 2865d8f2-773c-11ec-84a0-005056bb9f38
  RoutingKey: SJC12P01PAS02
  X-Rate-Limit-Group: medium
  X-Rate-Limit-Limit: 40
  X-Rate-Limit-Remaining: 39
  X-Rate-Limit-Window: 60
  Content-Type: application/json; charset=utf-8
  Content-Length: 60
  Content-Language: en-US
}

thanks for any and all help

sending 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.

Phong Vu avatar image
Phong Vu answered

Based on your app analytics, I see you have 2 successful /sms POST calls, and other calls failed with 400, 401 and 513. Can you check and compare what did you change in your code that caused the failure?screen-shot-2022-01-17-at-81728-am.png


1 |3000

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

ken-nye6499 avatar image
ken-nye6499 answered ken-nye6499 commented

as far as I can tell, I never got a successful post. can those success posts be the 'try it out' posts?

6 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.

Phong Vu avatar image Phong Vu ♦♦ commented ·

Then again, I believe that it's your PowerShell code that could convert the data in wrong format. Can you remove the plus sign from the number and try again.

0 Likes 0 ·
ken-nye6499 avatar image ken-nye6499 Phong Vu ♦♦ commented ·

I did test with the + and it made no difference, and the powershell code does work with HighVolume SMS, so I dont see why it would not work with regular SMS
This is how the powershell outputs to JSON

$AuthBodyTxt   = [pscustomobject]@{"from" = @{"phoneNumber"    = "+15555552434"};
                    "to"    = @(@{"phoneNumber"    = "+15555552586"});
                    "text"     = "$($message)"
}
 $AuthBodyTxt|ConvertTo-JSON -Depth 3
#------------
{
  "to": [
    {
      "phoneNumber": "+15555552434"
    }
  ],
  "from": {
    "phoneNumber": "+15555552586"
  },
  "text": "Test Message is blank"
}

I then just created the format without using ConvertTo-Json like this

 $nojson = "{
    $([char]34)to$([char]34): [{$([char]34)phoneNumber$([char]34): $([char]34)+15555552434$([char]34)}],
    $([char]34)from$([char]34): {$([char]34)phoneNumber$([char]34): $([char]34)+15555552586$([char]34)},
    $([char]34)text$([char]34): $([char]34)Test Message$([char]34)
  }"
  write-host $nojson
{
    "to": [{"phoneNumber": "+15555552434"}],
    "from": {"phoneNumber": "+15555552586"},
    "text": "The ARG is blank"
  }	

which gives the exact format shown in the reference guide. When search for unsupported media type

0 Likes 0 ·
ken-nye6499 avatar image ken-nye6499 ken-nye6499 commented ·

When searched for unsupported media type, I found someone saying that the Content-Type is not correct. This is what I have in my header

  $Header = @{"ContentType" = 'application/json'
            "accept" = "application/json"
            "authorization" = "Bearer $Bearer"
            }   

is that correct?

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