Creating http_request with a stream and a complex body

Mar 1 at 12:01 PM
Edited Mar 1 at 12:02 PM
Hi All,
I'm trying to write a C++ client for posting messages and images into HipChat, using cpprestsdk. I succeeded posting a message but got stuck with uploading an image file.
From HipChat REST API documentation (

Example Request:
Content-Type: multipart/related; boundary=boundary123456

Content-Type: application/json; charset=UTF-8
Content-Disposition: attachment; name="metadata"

{"message": "Check out this file upload!"}
Content-Type: image/png
Content-Disposition: attachment; name="file"; filename="upload.png"

<file content goes here>

I'm trying to use the set_body() method:
void web::http::http_request::set_body(const concurrency::streams::istream& stream, ....)
but I cannot figure out how to inset all the above complex body along with the file stream. The documentation of set_body() says:
This cannot be used in conjunction with any other means of setting the body of the request.
Any idea?