I'm trying to imbed a binary zip file as an attachment in a post to a RESTful service using the httpclient in Appeon 2017 R3. I read the file into a blob and then have to convert it into a string for the body, so it looks like:
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="attachment"; filename="emanif_3552785JJK.zip"
Content-Type: application/x-zip-compressed
(binary string for zip goes here)
------WebKitFormBoundary7MA4YWxkTrZu0gW--
Powerbuilder code then looks like:
ls_raw += CRLF+'Content-Disposition: form-data; name="attachment"; filename="'+ ls_fname_in_zip+'"'+ &
CRLF+'Content-Type: application/x-zip-compressed; charset=utf-8' + &
CRLF+CRLF+ &
String(iblb_data, EncodingUTF8!) + &
CRLF+'--'+CS_BOUNDARY_FORM+'--'+CRLF
When the service parses this out, it extracts the string as a zip and tries to extract the file in the zip. Then it replies the zip file is corrupt. If I do not use EncodingUTF8!, it tells me it needs a zip file, not recognizing it.
I suspect that the string function is dropping the first characters. The help file says, "If the file is an ANSI or UTF-8 file and is read into a blob, FileReadEx saves the contents of the file with no conversion. The BOM is not written to the blob in text mode, but it is written to the blob in stream mode.
If the blob has a byte-order mark (BOM), String filters it out automatically."
So I'm thinking the string I use may be missing the BOM and I need to supply it. When I do, it no longer sees it as a proper file.
What am I missing?