question

Roman Rozum avatar image
Roman Rozum asked Phong Vu commented

400 bad request on send MMS

Hi,

I'm trying to send a mms-message using https://github.com/ringcentral-tutorials/sms-api-php-demo

I filled all the data in ".env". Here all correctly (I have goes send sms)

$ php send-sms.php
Message sent. Message delivery status: Queued

The message does reach (I check Glip chat)


But mms message cannot be sent. Get the error:

$ php send-mms.php
Expected HTTP Error: 400 Bad Request (and additional error happened during JSON parse: Response is not JSON)

And moreover, if we consider the response in more detail, it contains only the text of the error "Bad request" and nothing else.


I tried sending a very small file (~100 bytes). And it works!

Message sent. Message delivery status: Queued


I don't understand how it should work and how I should use it in my app. I think it's some kind of bug and it should not be. Tell me, what should I do with it?

rest api
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

You said you send a very small file and it works, that means that the code is working as expected. I doubt that you try to send some big file or unsupported content. So check out the MMS capabilities below.

RingCentral supported MMS content types

  • Images: jpg/jpeg, png, gif, bmp, tif/tiff, svg
  • Videos: 3gp, mp4, mpeg, flv, wmv, mov
  • Audio: mp3
  • Files: vcf/vcard, zip, rtf, html

Attachment size limit

The maximum size for MMS is carrier-dependent and normally around 1.2MB to 1.4MB.

You can send multiple attachments in a single MMS message. But the total size of attachments should not exceed the size limit above!

Also, if you want to see more from the error, change or print whatever from the exception you want to see within this block:

}catch (\RingCentral\SDK\Http\ApiException $e) {
  print 'Expected HTTP Error: ' . $e->getMessage() . PHP_EOL;
}
1 |3000

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

Roman Rozum avatar image
Roman Rozum answered Phong Vu commented

@Phong Vu

I am sending a jpg which is attached in the project (test.jpg). It has a size of 16.1 KB.

I know about the ability to get additional information from the Exception. But the $e does not contain anything except "code" - 400 and "message" - Bad Request

$e->apiResponse()->response()

Prints this object:

object(GuzzleHttp\Psr7\Response)#45 (6) {
  ["reasonPhrase":"GuzzleHttp\Psr7\Response":private]=>
  string(11) "Bad Request"
  ["statusCode":"GuzzleHttp\Psr7\Response":private]=>
  int(400)
  ["headers":"GuzzleHttp\Psr7\Response":private]=>
  array(4) {
    ["Server"]=>
    array(1) {
      [0]=>
      string(5) "nginx"
    }
    ["Date"]=>
    array(1) {
      [0]=>
      string(29) "Thu, 19 Dec 2019 16:45:36 GMT"
    }
    ["Content-Length"]=>
    array(1) {
      [0]=>
      string(1) "0"
    }
    ["Connection"]=>
    array(1) {
      [0]=>
      string(5) "close"
    }
  }
  ["headerNames":"GuzzleHttp\Psr7\Response":private]=>
  array(4) {
    ["server"]=>
    string(6) "Server"
    ["date"]=>
    string(4) "Date"
    ["content-length"]=>
    string(14) "Content-Length"
    ["connection"]=>
    string(10) "Connection"
  }
  ["protocol":"GuzzleHttp\Psr7\Response":private]=>
  string(3) "1.1"
  ["stream":"GuzzleHttp\Psr7\Response":private]=>
  object(GuzzleHttp\Psr7\Stream)#43 (7) {
    ["stream":"GuzzleHttp\Psr7\Stream":private]=>
    resource(75) of type (stream)
    ["size":"GuzzleHttp\Psr7\Stream":private]=>
    NULL
    ["seekable":"GuzzleHttp\Psr7\Stream":private]=>
    bool(true)
    ["readable":"GuzzleHttp\Psr7\Stream":private]=>
    bool(true)
    ["writable":"GuzzleHttp\Psr7\Stream":private]=>
    bool(true)
    ["uri":"GuzzleHttp\Psr7\Stream":private]=>
    string(10) "php://temp"
    ["customMetadata":"GuzzleHttp\Psr7\Stream":private]=>
    array(0) {
    }
  }
}

1576774019185.png (215.9 KiB)
1 comment
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 ·

This code works well for me and many others. And also you said it works for a small attachment. So I am not sure what is different in your environment. Have you tried with a different attachments?

0 Likes 0 ·

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