You can use the Qp0lSetAttr API as well to do this instead of using a command to execute.
Original Message:
Sent: Thu April 30, 2026 02:44 PM
From: Michael Soucy
Subject: REST call from IBMi to a MS SQL Server database
Hi Daniel,
One more thing I wanted to share with you regarding this process. When went to run the Jack Henry process that uses these files it failed. It said it could not read the file. What I discovered was that the character set ID was 1208. I checked the character set of what the files were when I downloaded them manually via Postmam they were 437. I created a sub procedure in the RPG program to change the character set ID and that fixed the problem.
Here's my code:
// --------------------------------------------------
// Procedure name: ChangeCharSet
// Purpose: Change the IFS file to the correct character set
// Returns:
// Parameter: p1_ifs_file_name
// --------------------------------------------------
dcl-proc ChangeCharSet;
dcl-pi *N;
p1_ifs_file_name CHAR(255);
end-pi;
// Local fields
dcl-c CHGATR 'CHGATR OBJ(''%IFS_FILE%'') ATR(*CCSID) VALUE(437)';
// Calculation specifications
CmdString = CHGATR;
CmdString = %scanrpl('%IFS_FILE%':%trim(p1_ifs_file_name):CmdString);
Monitor;
Command(%trimr(CmdString):%len(%trimr(CmdString)));
on-error;
endmon;
return;
end-proc;
Thank you again for all your help with this. It has been a great learning experience for me.
------------------------------
Michael Soucy
Sr Midrange Engineer
Bangor Savings Bank
Bangor ME
------------------------------
Original Message:
Sent: Wed April 29, 2026 01:22 PM
From: Daniel Gross
Subject: REST call from IBMi to a MS SQL Server database
Perfect - glad it works - and yes the HTTP options are some kind of "alchemy" for us RPG developers ...
I will make some blog post about it - thanks for your feedback.
Regards,
Daniel
Original Message:
Sent: 4/29/2026 12:54:00 PM
From: Michael Soucy
Subject: RE: REST call from IBMi to a MS SQL Server database
Hi Daniel,
I ended up opening a case with IBM. We were able to figure out what the issues were by looking at some logs. The items I was missing was I had to add "redirect":"5" to the call parameters and that did it. I updated the RPG code you provided and was able to prove that I could download all 7 files to the IFS. This is my RPG code. I'm going to clean it up, and change the IFS folder to where it actually needs to go to for the Jack Henry OFAC process. Thank you for your help with this!
**FREE
ctl-opt dftactgrp(*no);
dcl-s ifs_file sqltype(CLOB_FILE);
ifs_file_fo = SQFOVR; // overwrite file contents
ifs_file_name = '/SOUCYMI/JHAOFAC/sdn.xml';
ifs_file_nl = %len(%trimr(ifs_file_name));
exec sql set :ifs_file =
http_get('https://sanctionslistservice.ofac.treas.gov/api/download/sdn.xml',
'{"sslTolerate":"true", "redirect":"5"}');
if sqlcode <> *zero;
// error
endif;
ifs_file_name = '/SOUCYMI/JHAOFAC/cons_add.csv';
ifs_file_nl = %len(%trimr(ifs_file_name));
exec sql set :ifs_file =
http_get('https://sanctionslistservice.ofac.treas.gov/api/download/cons_add.csv',
'{"sslTolerate":"true", "redirect":"5"}');
if sqlcode <> *zero;
// error
endif;
ifs_file_name = '/SOUCYMI/JHAOFAC/cons_alt.csv';
ifs_file_nl = %len(%trimr(ifs_file_name));
exec sql set :ifs_file =
http_get('https://sanctionslistservice.ofac.treas.gov/api/download/cons_alt.csv',
'{"sslTolerate":"true", "redirect":"5"}');
if sqlcode <> *zero;
// error
endif;
ifs_file_name = '/SOUCYMI/JHAOFAC/cons_prim.csv';
ifs_file_nl = %len(%trimr(ifs_file_name));
exec sql set :ifs_file =
http_get('https://sanctionslistservice.ofac.treas.gov/api/download/cons_prim.csv',
'{"sslTolerate":"true", "redirect":"5"}');
if sqlcode <> *zero;
// error
endif;
*inlr = *on;
ifs_file_name = '/SOUCYMI/JHAOFAC/alt.ff';
ifs_file_nl = %len(%trimr(ifs_file_name));
exec sql set :ifs_file =
http_get('https://sanctionslistservice.ofac.treas.gov/api/download/alt.ff',
'{"sslTolerate":"true", "redirect":"5"}');
if sqlcode <> *zero;
// error
endif;
*inlr = *on;
ifs_file_name = '/SOUCYMI/JHAOFAC/add.ff';
ifs_file_nl = %len(%trimr(ifs_file_name));
exec sql set :ifs_file =
http_get('https://sanctionslistservice.ofac.treas.gov/api/download/add.ff',
'{"sslTolerate":"true", "redirect":"5"}');
if sqlcode <> *zero;
// error
endif;
*inlr = *on;
ifs_file_name = '/SOUCYMI/JHAOFAC/sdn.ff';
ifs_file_nl = %len(%trimr(ifs_file_name));
exec sql set :ifs_file =
http_get('https://sanctionslistservice.ofac.treas.gov/api/download/sdn.ff',
'{"sslTolerate":"true", "redirect":"5"}');
if sqlcode <> *zero;
// error
endif;
*inlr = *on;
------------------------------
Michael Soucy
Sr Midrange Engineer
Bangor Savings Bank
Bangor ME
Original Message:
Sent: Thu April 23, 2026 04:08 PM
From: Daniel Gross
Subject: REST call from IBMi to a MS SQL Server database
Can it be, that your URL constant is missing the protocol?
Shouldn't it be like this?
And have you checked the IFS permissions of the file and directory?
HTH
Daniel
Original Message:
Sent: 4/23/2026 3:27:00 PM
From: Michael Soucy
Subject: RE: REST call from IBMi to a MS SQL Server database
Hi Daniel,
I think I'm getting closer. The error is saying I need an SSL certificate. I put the SSL cert into DCM following the instructions here:
Configuring IBM i DB2 QSYS2 HTTP Functions for TLS/HTTPS Secure Communications
When I run this RPG code it creates a file on the IFS, but it's empty. Could our Firewall be blocking me from connecting to ofac.treas.gov?
ctl-opt dftactgrp(*no);
dcl-s ifs_file sqltype(CLOB_FILE);
dcl-c url 'https://sanctionslistservice.ofac.treas.gov/api/download/-
cons_add.csv';
ifs_file_fo = SQFOVR; // overwrite file contents
ifs_file_name = '/JHA/JHAOFAC/cons_add.csv';
ifs_file_nl = %len(%trimr(ifs_file_name));
exec sql set :ifs_file =
http_get(:url,'{"sslTolerate":"true"}');
if sqlcode <> *zero;
// error
endif;
*inlr = *on;
Thank you!
------------------------------
Michael Soucy
Sr Midrange Engineer
Bangor Savings Bank
Bangor ME
Original Message:
Sent: Thu April 23, 2026 11:23 AM
From: Daniel Gross
Subject: REST call from IBMi to a MS SQL Server database
Hi Michael,
well - the code should do that already. The variable IFS_FILE is declared and configured as a SQL-Type CLOB_FILE - which is automatically writing the contents that you set to the IFS file where the "sub-variable "_NAME" points. You can read about CLOB_FILE in the Info Center.
The SQLCODE = -443 is a generic SQL code that signals an exception in a function or procedure. So you might have to diagnose the messages in the job log before that SQL0443 message - there should be some AXIS error messages from the C++ framework that does the work in the background.
HTH
Daniel
Original Message:
Sent: 4/23/2026 10:07:00 AM
From: Michael Soucy
Subject: RE: REST call from IBMi to a MS SQL Server database
Hi Daniel Gross,
I wrote an RPG program using your code. When I try and run it, I get a sqlcode error -443. That seems to indicate that I need a certificate to download do the HTTP_GET function. How do I save the results to a file on the IFS after the HTTP_GET?
Thank you!
------------------------------
Michael Soucy
Sr Midrange Engineer
Bangor Savings Bank
Bangor ME
Original Message:
Sent: Fri April 10, 2026 10:11 AM
From: Daniel Gross
Subject: REST call from IBMi to a MS SQL Server database
What kind of file is that? Some sort of text/CSV, JSON or XML? Or something "binary"?
You want the file to end up in the IfS? OK - there are several solutions for that. But the most straightforward would be, to declare a LOB-file variable in RPG and use it as the target of your HTTP_GET.
The smallest example would be like this:
dcl-s ifs_file sqltype(CLOB_FILE);
ifs_file_fo = SQFOVR; // overwrite file contents
ifs_file_name = '...your ifs path and file...';
ifs_file_nl = %len(%trimr(ifs_file_name));
exec sql set :ifs_file = http_get('...url...');
if sqlcode <> *zero;
// error
endif;
Please be advised, I'm on a road trip right now, and I don't have access to an IBM i - there might be errors and I might be wrong - that's what I recall from memory.
HTH
Daniel
Original Message:
Sent: 4/10/2026 9:28:00 AM
From: Michael Soucy
Subject: RE: REST call from IBMi to a MS SQL Server database
Hi Daniel,
I appreciate your offer to help me. Using these HTTP calls is all new to me. I seem to be struggling on how this works. I was hoping to find some examples in the ACS SQL tool, but I didn't see any.
Thank you!
------------------------------
Michael Soucy
Sr Midrange Engineer
Bangor Savings Bank
Bangor ME
Original Message:
Sent: Fri April 10, 2026 09:17 AM
From: Daniel Gross
Subject: REST call from IBMi to a MS SQL Server database
Of course Michael.
You get the result as a CLOB (HTTP_GET) or BLOB (HTTP_GET_BLOB) - and then store it in an IFS file, or in a CLOB/BLOB field in a table.
If you need more support please contact me.
HTH
Daniel
Original Message:
Sent: 4/10/2026 8:56:00 AM
From: Michael Soucy
Subject: RE: REST call from IBMi to a MS SQL Server database
Can you use HTTP_GET for something simple as downloading a file a webservice? I had been working on a GoAnywhere project for something else I've gotten stuck. I wonder if the HTTP_GET would be easier. I can download the files using Postman, but I would be better if I could do it directly on the IBMi. This is what I put in for a GET operation in Postman and it worked.
https://sanctionslistservice.ofac.treas.gov/api/download/{filename}
{filename} is the OFAC file I need to download.
Would this be simpler using HTTP_GET? I'd like the results to put into a file on the IFS.
------------------------------
Michael Soucy
Sr Midrange Engineer
Bangor Savings Bank
Bangor ME
Original Message:
Sent: Thu April 09, 2026 02:04 PM
From: Daniel Gross
Subject: REST call from IBMi to a MS SQL Server database
A while ago, I wrote a small blog post about using JSON_TABLE, which also uses QSYS2.HTTP_GET to retrieve the results of a web service call.
Maybe this helps a bit - there are also some good examples in the docs:
I even have an example somewhere, which uses JSON_OBJECT to create the HTTP-options for the HTTP_GET call.
And FWIW - HTTP_GET_BLOB retrieves a binary large object from the server - like a JPEG or PDF file - if you receive JSON or XML you use HTTP_GET, HTTP_POST or whatever "verb" you need.
HTH
Daniel