Uploading Files (Multipart MIME)
Multipart MIME is a standard used for uploading files to webservers. All the API resources which support file uploads in ET use this standard.
Uploads look like this:
POST /EnterpriseTester/api/stepresult/25eb6aa0-3514-48bf-8c59-a21200d7a6fc/attachments HTTP/1.1 Host: 127.0.0.1 Content-Type: multipart/mixed; boundary=65bf6b94-c91c-442c-abe7-f41444d7c71f Content-Length: 3 Authorization: Basic bGFidmlldzpvbnNhbGE= --65bf6b94-c91c-442c-abe7-f41444d7c71f Content-Disposition: attachment; filename="notes.txt"; name=notes; size=3 Content-Type: text/plain Content-Length: 3 ABC --65bf6b94-c91c-442c-abe7-f41444d7c71f--
Typically - a library will generate this for you - but if you are generating it yourself then the key points are as follows:
- Content type set to "multipart/mixed".
- A "boundary=[something unique]"
- The boundary starts and ends the body of the POST. (with -- at the start and --[boundary]-- at the end)
- There must be a blank line between the headers for the part and the part content. (in the example - between Content-Length: 3 and ABC)