Hi Richard,
I have used the following code just a few weeks ago. See if it works for you. I have not used any external api or third party or copy books etc. By the way this piece of the code I have got it from Claude code. I have built and deployed the rest api provider on IWS. And the processing program is in SQL RPGLE. I have used it to extract the JWT bearer token to be received in the rest api header. Interesting to see how your solution can work without any of the servers from the performance point of view.
dcl-s headerUtf8 varchar(256) ccsid(*utf8);
dcl-s headerJob varchar(256);
headerUtf8 = %str(getenv('HTTP_AUTHORIZATION'));
headerJob = headerUtf8; // implicit conversion to job CCSID
Ramraj Kasamsetty
m (214) 406 8243
https://www.linkedin.com/in/ramrajkasamsetty
https://twitter.com/ramkasamsetty
From: Richard Schoen <richard@xxxxxxxxxxxxxxxxx>
To: "rpg400-l@xxxxxxxxxxxxxxxxxx"<rpg400-l@xxxxxxxxxxxxxxxxxx>
Date: Mon, 15 Jun 2026 17:37:34 -0500
Subject: SQLRPGLE CGI Program with Minimal Stack
Hi All,
I’m working on doing a sample minimalist CGI Web API program that uses no external API stack other than what the OS provides along with SQL in an RPGLE program.
I essentially want to see what a lightweight RPG CGI REST architecture might be in today’s arena.
I know there are frameworks like IWS, HTTPAPI, YAJL and NOXDB, CGIDEV2 etc that can be used as helpers.
I also know I can use Python, PHP, Node, Java etc. I want this ONLY to be SQLRPGLE.
This is a POC to see if I can do a minimalist approach to CGI. And even AI keeps screwing things up as far as appropriate API definitions and data conversion :-)
The biggest issue is handling the UTF-8 data conversion.
Also for context it’s been a few years since I’ve worked much with RPGLE and CGI. And I’m going all in on SQLRPGLE and JSON_TABLE/JSON_OBJECT with this sample.
Basically I want to:
-Take in a posted JSON packet. (Works)
-Read the request data QtmhRdStdIn. (Works but it appears to be raw UTF-8 data. I think)
-Convert and review the URL data and JSON and convert it to something readable in RPGLE as it appears to be coming in as UTF-8.
-Run an SQL using JSON values extracted from the JSON request using JSON_TABLE.
-Run the SQL query.
-Turn around and output the results as JSON
My only real stumbling block is converting the incoming and outgoing data correctly from and back to UTF-8. And that may also be an Apache configuration issue as far as character conversion. ICONV may be part of the answer but even AI comes up with long answers that didn’t seem to work as I had to use the 80/20 where it gave me 80% and I had to punt on the 20%.
Anyway, any insights relevant to the constraints I laid out are appreciated in case anyone else has already been there when playing with SQLRPGLE, CGI and JSON.
Regards,
Richard Schoen
Web:
http://www.richardschoen.net
Email: mailto:richard@xxxxxxxxxxxxxxxxx