This doesn't sound related to HTTPAPI. HTTPAPI is for consuming HTTP URLs, not for providing them.
YAJL can be used to do the JSON portion of it. YAJL is a JSON tool -- it specializes in JSON, it doesn't know anything about other formats such as MIME or whatever format your attachment is expected to be in.
You'll need to write a multipart encoder -- this isn't too difficult.
The output you'll need to write will look something like this:
Code: Select all
Status: 200
Content-Type: multipart/form-data; boundary=BOUNDARY--2023-07-03-12:13:14.000000
--BOUNDARY--2023-07-03-12:13:14.000000
Content-Disposition: form-data; name="myjsondata"; filename="my_file.json"
Content-Type: application/json
{ "json": "data here" }
--BOUNDARY--2023-07-03-12:13:14.00000
Content-Disposition: form-data; name="other.file.here"; filename="other_file.dat"
Content-Type: application/octet-stream
whatever the data in the attachment should be
--BOUNDARY--2023-07-03-12:13:14.00000--
The boundary can be anything that doesn't appear in the actual content -- I tend to like to put the timestamp in there figuring that the odds of it being in the content are rare, plus even if it does happen to exist, if you retry, it'll be different the next time.
The boundary needs to be the same everywhere, though... except that each "part" of the multipart document (or "attachment" if you choose to think of it that way) must start with an extra "--". And the very end of the document must have "--BOUNDARY-HERE--" so must both start and end with "--".
You will need to know the correct Content-Type for whatever you're sending... you were vague on what else besides JSON is involved here.
Once you've built the data, you can send it with the QtmhWrStout routine. (You can't use yajl_writeStdout, as this will only since the JSON data that YAJL has generated, and then will be done.)