AgileApps Support Wiki Pre Release

REST API:Multipart Request

From AgileApps Support Wiki

A multipart request lets you send a package of data that includes the typical XML or JSON request accompanied by other data (typically, the contents of a file).

Here's a sample request:

<syntaxhighlight lang="xml" enclose="div">

Content-Type: multipart/form-data; boundary=.............................103832778631715

--.............................103832778631715 Content-Disposition: form-data; name="__xml_part__"; Content-Type: application/xml;

<platform>

   {the XML portion of the request}

</platform>

.............................103832778631715 Content-Disposition: form-data; name="file_part"; filename="someImage.jpg" Content-type: application/octet-stream

{contents of the file} .............................103832778631715-- </syntaxhighlight>

Considerations
  • The Content-type of the request is set to multipart/form-data with an appropriate boundary.
  • The first part contains the information portion of request, with Content-type set to application/xml or application/json, as appropriate. The name of the part is either __xml_part__ or __json_data__.
  • The next part of the request is the actual file. The filename attribute for this part is the name of the file that is being uploaded. Here, the Content-type is application/octet-stream.
  • To send binary data over the wire, it must first be encoded. But for a CSV file, for example, the Content-type could be text/plain.