QSYS2.HTTP_GET

Discussions relating to writing software in ILE RPG (RPG IV). This includes both fixed and free format RPG.
Post Reply
kita
Posts: 1
Joined: Thu May 16, 2024 2:19 pm

QSYS2.HTTP_GET

Post by kita »

Here is the curl request that works
curl -X 'GET' \
'https://myfullurlhere' \
-H 'accept: text/plain' \
-H 'X-API-Key: myapikey'

The code is RPGLE **FREE
I am trying to use the SQL functions so here is how i set up my options
exec sql values json_object(
'basicAuth' value 'X-API-Key: myapikey',
'header' value 'accept: text/plain'
)
into :options;

then my call
exec SQL
values QSYS2.HTTP_GET(:urlRest, :options)
into :response;

This causes 38501 SQL error. Which isn't very useful in figuring out what is wrong.

Any ideas how to make this work?

Thanks, Kita

I've tried many versions of the options but nothing seems to work correctly and I always get the 38501 SQL error.
The error in the joblog is as follows.
Additional Message Information

Message ID . . . . . . : CPF503E Severity . . . . . . . : 30
Message type . . . . . : Sender copy
Date sent . . . . . . : 05/16/24 Time sent . . . . . . : 10:09:01

Message . . . . : User-defined function error on member QSQPTABL.
Cause . . . . . : An error occurred while invoking user-defined function
HTTP_GET in library QSYS2. The error occurred while invoking the associated
external program or service program QSQAXISC in library QSYS, program entry
point or external name axiscGetClob, specific name HTTP_GET. The error
occurred on member QSQPTABL file QSQPTABL in library QSYS2. The error code
is 1. The error codes and their meanings follow:

Thank you in advance.
Kita
Scott Klement
Site Admin
Posts: 799
Joined: Sun Jul 04, 2021 5:12 am

Re: QSYS2.HTTP_GET

Post by Scott Klement »

In the Curl example, you are telling it to use X-API-Key as a header with a value of myapikey.

In the HTTP_GET example, you are telling it to sign in with a userid and password, and that the userid to use is "X-API-Key: myapikey". That's very different from sending it as a header...

Don't send it as a userid. Send it as a header.

For the Accept header, you are sending it as a header, but aren't formatting it correctly.

Please consider reading the documentationt to understand how to send headers via HTTP_GET.

If you want further help from me, consider changing to HTTPAPI. Please don't expect me to provide technical support for product that, technically, competes with mine.
Post Reply