REST API:Multipart Request

From AgileApps Support Wiki
Revision as of 22:52, 3 September 2010 by imported>Aeric
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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:

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

--.............................103832778631715
Content-Disposition: form-data; name="xml_part1;
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--
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 names and attributes of the different parts will vary, depending on the API.)
  • 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.