smsmmsringcentral

Is it possible to send RingCentral SMS / MMS using multipart/form-data?


The OpenAPI spec for the Create SMS Message endpoint includes the following request content types:

  consumes:
  - application/json
  - multipart/mixed
  - multipart/form-data

I found the SMS / MMS instructions to include a multipart/mixed example in the API Reference, but don't see any information on using multipart/form-data. I'm specifically interested in sending files.

https://developers.ringcentral.com/api-reference/SMS/createSMSMessage

The same API Reference shows support for both multipart/form-data and multipart/mixed for sending faxes.

https://developers.ringcentral.com/api-reference/Fax/createFaxMessage

Since both APIs send files and metadata so I'm wondering if the SMS API also supports multipart/form-data and, if so, how to send it?


Solution

  • multipart/form-data can be sent as shown in the following example:

    POST / HTTP/1.1
    HOST: platform.ringcentral.com/restapi/v1.0/account/~/extension/~/sms
    Authorization: Bearer <MyToken>
    Content-Type: multipart/form-data; boundary=12345
    
    --12345
    Content-Disposition: form-data; name="to"
    
    +16505550101
    --12345
    Content-Disposition: form-data; name="to"
    
    +16505550102
    --12345
    Content-Disposition: form-data; name="from"
    
    +16505550100
    --12345
    Content-Disposition: form-data; name="text"
    
    Hello World
    --12345
    Content-Disposition: form-data; name="attachment" filename="picture.jpg"
    
    content of picture.jpg ...
    --12345--
    

    This can be done using curl as follows:

    curl -XPOST https://platform.ringcentral.com/restapi/v1.0/account/~/extension/~/sms \
    -H 'Authorization: Bearer <MyToken>' \
    -F 'to=+16505550101' \
    -F 'to=+16505550102' \
    -F 'from=+16505550100' \
    -F 'text=Hello World' \
    -F 'attachment=@picture.jpg'