question

Khiem Nguyen avatar image
Khiem Nguyen asked Khiem Nguyen commented

Sending an MMS was a Bad Request

At the first, I received a response message like this:

{
  "message": "Bad Request",
  "errors": []
}

and this is my request payload:

{
  "from":{"phoneNumber":"+19292561865"},
  "to":[{"phoneNumber":"+14707816202"}], 
  "text":"mms testing",
  "attachments":["data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAEBAQEBAQEBAQEBAQECAgMCAgICAgQDAwIDBQQFBQUEBAQFBgcGBQUHBgQEBgkGBwgICAgIBQYJCgkICgcICAj..."]
}
Content-type: multipart/mixed

I found out that I can use MmsSender with my account, too.

I, therefore, wonder whether I'm missing something or if there are any permissions I need to specify but haven't?

Content-Type:
multipart/mixed
messagesending 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 Khiem Nguyen commented

What programming language are you writing your code? Why don't you use one of the RingCentral SDKs?

Check this out to see how to use an SDK to send MMS messages. If you are using CURL, see the following sample code:

curl -X POST 'https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/mms' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <valid-access-token' \
-F 'request={"from":{"phoneNumber":"+1312xxxyyyy"},"to":[{"phoneNumber":"+1650xxxyyyy"}],"text":"By CURLing"};type=application/json' \
-F 'attachment=@test3.png;type=image/png'
2 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.

I got confused by the API Send MMS described attachments that are arrays and must be base64. So, the first question is, are array attachments and single attachments both correct?

And second, I want to try to use Postman to send MMS with data like down below. Will it work?

{
  "from":{"phoneNumber":"+1929xxxyyyy"},
  "to":[{"phoneNumber":"+1470xxxyyyy"}], 
  "text":"mms testing",
  "attachments":["data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAAEBAQEBAQEBAQEBAQECAgMCAgICAgQDAwIDBQQFBQUEBAQFBgcGBQUHBgQEBgkGBwgICAgIBQYJCgkICgcICAj..."]
}
  1. Content-type: multipart/form-data

If not, could you suggest to me how to convert the upper JSON to Form-data in Postman or any way that can run with Postman?

Thanks

0 Likes 0 ·

I did it. After checking out how the SDK works, I looked at my code and adjusted it using Blob with content-type=application/json. Then, the magic occurred.

Thanks

1657642961238.png

1657642850582.png

0 Likes 0 ·
1657642850582.png (20.8 KiB)
1657642961238.png (45.2 KiB)

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