Page 1 of 1

HTTP_STMF PUT

Posted: Wed Sep 14, 2022 2:53 am
by cea_1964@yahoo.com
Good evening.....

I am using HTTP_STMF to PUT .csv's to AWS' S3 buckets.

The issue I am having involves the parameters. Note: Trailing portion of the URL is the file name. Per AWS.
In my RPG if I "DCL-S URL Char(124);" the process works fine since my complete url is 124 characters.
If I make URL any larger, I get %20%20%20 placed on the end, making the URL invalid when it reaches AWS.

Having similar issue with the send file name in the 4th parameter. If my field length on the declare is not the exact length of the file name, I get No such Path in the response.

My naming convention is such that i can get by with having my field lengths exact, but I'm fearful I will eventually need to make them variable.

Dcl-PR WSAWS_RO;
*n Char(250);
End-PR;
Dcl-PI WSAWS_RO;
pIFSFileName Char(250);
End-PI;

Dcl-S url char(124);
Dcl-S IFSRcv char(5000);
Dcl-S IFSSnd char(38);

url = 'https://XXXXXXXXXX.execute-api.us-west-2.amazonaws.com/' +
'xxxxxxxxx/xxxxxxxxfulfillorder-mytools/' + %Trim(pIFSFileName);
IFSRcv = '/AWS_S3/WORKFILE.TXT';
IFSSnd = '/AWS_S3/' + %Trim(pIFSFileName);
http_stmf('PUT':url:IFSRcv:IFSSnd:'text/csv');

Any help appreciated.

Chris

Re: HTTP_STMF PUT

Posted: Wed Sep 14, 2022 2:59 am
by Scott Klement
Use the %TRIM BIF to remove the unwanted spaces.

http_stmf('PUT':%trim(url):%trim(IFSRcv):%trim(IFSSnd):'text/csv');

Or, alternately, use varchar fields instead of fixed-length fields.

Re: HTTP_STMF PUT

Posted: Fri Sep 16, 2022 12:57 am
by cea_1964@yahoo.com
Hi Scott,

Tried both VARCHAR and %Bif, same results.

It's interesting that if I hard code the IFSSnd, it works!

IFSRcv = '/AWS_S3/WORKFILE.TXT';
//IFSSnd = '/AWS_S3/' + %Trim(pIFSFileName);
IFSSnd = '/AWS_S3/318039_7101_20220912130444.CSV';

monitor;
http_stmf('PUT':%Trim(url):%Trim(IFSRcv):%Trim(IFSSnd):'text/csv');
On-error;
http_code = http_error();
ENDMON;

Re: HTTP_STMF PUT

Posted: Fri Sep 16, 2022 1:58 am
by Scott Klement
Are you passing the input value via the CALL command from the command-line? The problem with that is the caller will implicitly define the variable as CHAR(32) but since you're passing it to a CHAR(250) parameter, the remaining 218 bytes may contain garbage.

If that's the case, you can create a *CMD interface with the parameter defined to 250. Or you can create a CL program and pass a CHAR 250 variable for the parameter.

Re: HTTP_STMF PUT

Posted: Fri Sep 16, 2022 3:26 am
by cea_1964@yahoo.com
Yes, I was calling from a command line. All is well for now!

Thanks for the help! And everything!

Hope to see you in Denver!

Chris