Hi Dave,
I am not sure I can help, but I am going to try anyway.
In a couple of programs of mine I used getenv() function which, as per IBM
official documentation here
<
https://www.ibm.com/docs/en/i/7.4?topic=ssw_ibm_i_74/rzaie/rzaieapi_qtmhgetenv.htm>,
QtmhGetEnv is based on.
These programs are called through IWS so I know these environment variables
have already been set up by IWS itself when my program is called.
This is how I have it working:
dcl-ds RequestMetaData inz;
reqAuthType varchar(32) inz('');
reqQueryString varchar(256) inz('');
reqRemoteAddress varchar(32) inz('');
reqRemoteUser varchar(32) inz('');
reqMethod varchar(32) inz('');
reqURI varchar(128) inz('');
reqURL varchar(128) inz('');
reqServerName varchar(32) inz('');
reqServerPort varchar(16) inz('');
end-ds;
I found these variables' types and length definitions in IWS documentation
alongside with the environment variables' names, and that's how it works:
varPtr = GetEnv('AUTH_TYPE');
if varPtr = *NULL;
// environment variable not set
else;
reqAuthType = %str(varPtr);
endif;
varPtr = GetEnv('QUERY_STRING');
if varPtr = *NULL;
// environment variable not set
else;
reqQueryString = %str(varPtr);
endif;
varPtr = GetEnv('REMOTE_ADDR');
if varPtr = *NULL;
// environment variable not set
else;
reqRemoteAddress = %str(varPtr);
endif;
varPtr = GetEnv('REMOTE_USER');
if varPtr = *NULL;
// environment variable not set
else;
reqRemoteUser = %str(varPtr);
endif;
varPtr = GetEnv('REQUEST_METHOD');
if varPtr = *NULL;
// environment variable not set
else;
reqMethod = %str(varPtr);
endif;
varPtr = GetEnv('REQUEST_URI');
if varPtr = *NULL;
// environment variable not set
else;
reqURI = %str(varPtr);
endif;
varPtr = GetEnv('REQUEST_URL');
if varPtr = *NULL;
// environment variable not set
else;
reqURL = %str(varPtr);
endif;
varPtr = GetEnv('SERVER_NAME');
if varPtr = *NULL;
// environment variable not set
else;
reqServerName = %str(varPtr);
endif;
varPtr = GetEnv('SERVER_PORT');
if varPtr = *NULL;
// environment variable not set
else;
reqServerPort = %str(varPtr);
endif;
I don't know how your RPG program is called and if the HTTP instance you
are running fills your environment variables automatically.
Hope it helps.
Lucia
Il giorno ven 1 ott 2021 alle ore 10:04 Dave <dfx1@xxxxxxxxxxxxxx> ha
scritto:
Hi,
Having some problems using QtmhGetEnv for the first time.
QUERY_STRING : I can get the list of parameters but is there nothing
already written that will give me a list of parameters and their values for
an RPG program?
REQUEST_URI : The value returned is unreadable. I'm using Postman on a
windows PC to send the HTTP request.
Thanks in advance for any help.
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.
Help support midrange.com by shopping at amazon.com with our affiliate
link: https://amazon.midrange.com
As an Amazon Associate we earn from qualifying purchases.