
For Multipart requests, the HTTP header Content Type has to be set for identifying the request as a multipart request together with the boundary used. Furthermore the boundaries to seperate each request in the body has to be specified. The structure follows the MIME standard
(http://www.rfc-editor.org/rfc/rfc2046.txt) to place multiple message bodies into the HTTP body.
Example:
--34fe-f07f-960e
Content-Type: application/http
GET /Cars/1 HTTP/1.1
--34fe-f07f-960e
Content-Type: application/http
PUT /Cars/1 HTTP/1.1
Content-Type: application/xml
Content-Length: 1000
<?xml version="1.0" encoding="utf-8"?>
<asx:abap version="1.0" xmlns:asx="http://www.sap.com/abapxml">
<asx:values>
<CAR>
<ID>1</ID>
<MODEL_NAME>Golf 5 Plus</MODEL_NAME>
<MANU_ID>1</MANU_ID>
<PRICE>20399.99</PRICE>
<CURRENCY>EUR</CURRENCY>
<MODEL_YEAR>2012</MODEL_YEAR>
</CAR>
</asx:values>
</asx:abap>
--34fe-f07f-960e
Content-Type: application/http
GET /Cars/1 HTTP/1.1
--34fe-f07f-960e--
Using the REST library requests have to set the Content Type to value application/http for each request (i.e. the content type setting after the encapsulation boundary line). When sending data along within a single request, the request specific settings (the settings after the request lines) have to be made according to the following data; especially the Content Length setting cannot be omitted. Because each entry represents an own HTTP request, it is important to have the correct number of empty lines added.
The example multipart request body contains a GET for reading a resouce of type Car with ID=1, does a change on that resource via PUT method, and requests again via GET the same resource to read the now updated resource.
The request is send with the POST method to the server containing a x-csrf-token header value and the Content Type header with value multipart/mixed; boundary=34fe-f07f-960e.