Question

400 bad request on send MMS

  • 19 December 2019
  • 2 replies
  • 2264 views

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?


2 replies

Userlevel 1

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 (RingCentralSDKHttpApiException $e) {
  print 'Expected HTTP Error: ' . $e->getMessage() . PHP_EOL;
}

@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(GuzzleHttpPsr7Response)#45 (6) {
  ["reasonPhrase":"GuzzleHttpPsr7Response":private]=>
  string(11) "Bad Request"
  ["statusCode":"GuzzleHttpPsr7Response":private]=>
  int(400)
  ["headers":"GuzzleHttpPsr7Response":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":"GuzzleHttpPsr7Response":private]=>
  array(4) {
    ["server"]=>
    string(6) "Server"
    ["date"]=>
    string(4) "Date"
    ["content-length"]=>
    string(14) "Content-Length"
    ["connection"]=>
    string(10) "Connection"
  }
  ["protocol":"GuzzleHttpPsr7Response":private]=>
  string(3) "1.1"
  ["stream":"GuzzleHttpPsr7Response":private]=>
  object(GuzzleHttpPsr7Stream)#43 (7) {
    ["stream":"GuzzleHttpPsr7Stream":private]=>
    resource(75) of type (stream)
    ["size":"GuzzleHttpPsr7Stream":private]=>
    NULL
    ["seekable":"GuzzleHttpPsr7Stream":private]=>
    bool(true)
    ["readable":"GuzzleHttpPsr7Stream":private]=>
    bool(true)
    ["writable":"GuzzleHttpPsr7Stream":private]=>
    bool(true)
    ["uri":"GuzzleHttpPsr7Stream":private]=>
    string(10) "php://temp"
    ["customMetadata":"GuzzleHttpPsr7Stream":private]=>
    array(0) {
    }
  }
}

Reply