on 2024 Dec 13 9:11 AM
Hi,
There is some external web service. I need to call it and pass binary data to it.
For this purpose I have created my own procedure:
CREATE PROCEDURE "dba"."WebTest2Run"( in "data" long binary,in "cAccessToken" long varchar,in "nCustomerID" integer,in "filename" char(20) )
result( "cAttribute" long varchar,"cValue" long varchar,"npp" integer )
url 'http://OtherSite/WebTest1'
type 'HTTP:POST:application/pdf'
header 'Authorization: !cAccessToken; \x0AContent-Disposition: form-data; name="nCustomerID" !nCustomerID; \x0AContent-Disposition: form-data; name="files"; filename="!filename"'
I call it like this:
select * from dba.WebTest2Run(MyBinaryData, 'MyToken', 47, 'test.pdf')
where cAttribute = 'Body'
I need "Content-Disposition" to be specified twice in the header.
Content-Disposition: form-data; name="nCustomerID" 47
Content-Disposition: form-data; name="files"; filename="test.pdf"
But for some reason the second "Content-Disposition" setting overrides the first one, i.e. only the second setting remains in the header:
Content-Disposition = form-data; name="files"; filename="test.pdf"
Is there any way to fix this ?
And another question: When calling an external web service and passing binary data to it, is it possible to make http-header as in the picture below ?
In particular I am interested in the "boundary" and "muiltipart" parts of the http header ?
Request clarification before answering.
You need to do multipart for multiple Content-Dispositions and put them within the body parts, you can do it like this:
url 'api.endpoint.com'
set 'HTTP(EXCEPTIONS=off; VERSION=1.1)'
type 'HTTPS:POST:multipart/form-data'
header 'Connection:keep-alive \x0AAccept: */* \x0AContent-Type: multipart/form-data; boundary=XXXXboundary'
Then in your body you will need to list each of the boundaries for each part such as
'--XXXXboundary\x0D\x0AContent-Disposition: form-data; name="@"; filename="' || @fileName || '"\x0D\x0A\x0D\x0A' || replace(replace(@csvData,',0,',',0.01,'),',.',',0.') || '\x0D\x0A--XXXXboundary--'
Hope this gets you going in the right direction.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is how I have got it working, ultimately however you do it, in whatever language, you will need the client to conform, I guess you might have just use languages that have libraries available where someone else has done all this as reusable code?
Personally I like have full control over the raw transmission.
You will need to use whatever encoding the endpoint is expecting, it isn't always BASE64.
You can read more about encoding here: https://www.w3.org/Protocols/rfc1341/5_Content-Transfer-Encoding.html
But yes if you haven't stored the data in your tables BASE64 encoded and they want BASE64 encoded you will need to use BASE64_ENCODE()
User | Count |
---|---|
53 | |
5 | |
5 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.