#XPRIM_JsonWriter & WriteBase64StringFromFile
Posted: Fri Feb 23, 2024 5:23 am
Scenario:
VL web application for communicating with business partner REST API application (http put). Our server is IBM i.
New requirement from partner is to upload file in base64 in the http put request.
I read in other posts that the WriteBase64StringFromFile is good up to 16Meg, due to limitation on the IBM i. I am limiting the selected file to 10Meg to ensure we stay under this limit.
Previous request with base64 strings were fairly small, so no issues. But now converting the file to base64 string makes the message rather long:
DEFINE_COM Class(#XPRIM_HttpRequest) Name(#HttpRequest) Scope(*Application)
DEFINE_COM Class(#XPRIM_JsonWriter) Name(#Writer)
#Writer.WriteBase64StringFromFile Name('Document') Filepath(#IXI_FILEBLOB)
* This works, and doing a bit of debugging I can verify the content is built.
My issue is that I get an http 400 error when I try to execute http put request. Looking at the http response, it states the elements document and root are not closed. Trying to catch the outbound request data, it looks like the request is getting truncated at it is sent out.
I am thinking my issue is the command to add the content:
* Add completed string to the request
#HttpRequest.Content.AddString Value(#Writer.AsString)
with the .AddString intrinsic, is this really using the attributes of *String so a limit of 65535 ?
How, or what would be the appropriate way to generate the base64string and include it in the http get request (not as an attachment)?
VL web application for communicating with business partner REST API application (http put). Our server is IBM i.
New requirement from partner is to upload file in base64 in the http put request.
I read in other posts that the WriteBase64StringFromFile is good up to 16Meg, due to limitation on the IBM i. I am limiting the selected file to 10Meg to ensure we stay under this limit.
Previous request with base64 strings were fairly small, so no issues. But now converting the file to base64 string makes the message rather long:
DEFINE_COM Class(#XPRIM_HttpRequest) Name(#HttpRequest) Scope(*Application)
DEFINE_COM Class(#XPRIM_JsonWriter) Name(#Writer)
#Writer.WriteBase64StringFromFile Name('Document') Filepath(#IXI_FILEBLOB)
* This works, and doing a bit of debugging I can verify the content is built.
My issue is that I get an http 400 error when I try to execute http put request. Looking at the http response, it states the elements document and root are not closed. Trying to catch the outbound request data, it looks like the request is getting truncated at it is sent out.
I am thinking my issue is the command to add the content:
* Add completed string to the request
#HttpRequest.Content.AddString Value(#Writer.AsString)
with the .AddString intrinsic, is this really using the attributes of *String so a limit of 65535 ?
How, or what would be the appropriate way to generate the base64string and include it in the http get request (not as an attachment)?