Multipart Form - 400 Bad Request

699 views Asked by At

I'm having some trouble with a an API request I'm trying to make. Here is my POST request URL:

https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/fax

Request content type: multipart form

Header name and value:

enter image description here

Review:

enter image description here

Any idea why this may be happening? Thank you all!

1

There are 1 answers

0
Suyash On

multipart/form-data can be sent as shown in the following example with image attachment:

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 '[email protected]'

References :