× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.





I am creating a proof-of-concept REST application on our iSeries and I have the majority of it working but I am not getting the JSON returned in the response body. I added code that sends a message to QHST so I know the service is getting called and the URI retrieved in the code is correct. I've include the code below. When I execute the endpoint http://iSeriesName/web/services/ORDERS/123456789123 from Fiddler the Response Header returned is HTTP/1.1 200 OK but there is no response body. How do I return my JSON in the response body?



This is what appears in QHST showing the program variables retrieved:


---> Version 1.0 <---
/web/services/ORDERS/123456789123
refOrderNumber: 123456789123
Building data field
--->Send Response Data Field: Status: 500 Invalid URI??Content-type: text/json????{ "success": false, "errmsg": "Invalid URI!"}??



This is the program code:


**free

ctl-opt BndDir('QC2LE': 'COMBNDDIR')

PgmInfo(*pcml: *module) DecEdit('0.');


dcl-pr getenv pointer extproc(*dclcase);

var pointer value options(*string);

end-pr;


dcl-pr QtmhWrStout extproc('QtmhWrStout');

dtaVar char(65535) options(*varsize) const;

dtaCarLen int(10) const;

errorCode char(8000) options(*varsize);

end-pr;


dcl-pr SysCmd int(10) extproc('system');

*n pointer value options(*string);

end-pr;


dcl-s sysErrMsg char(7) import('_EXCP_MSGID');


dcl-ds err qualified;

bytesProv int(10) inz;

bytesAvail int(10) inz;

end-ds;


dcl-s bigCharVar char(100000) inz;

dcl-s httpHeader char(500) inz;

dcl-s charVar char(500) inz;

dcl-s data char(5000) inz;

dcl-s lengthOfJSON int(10) inz;

dcl-s msgQHST char(512) inz;


dcl-c CRLF const(X'0d25');

dcl-c q const(X'7D');


dcl-s uri varchar(5000) inz;

dcl-s httpStatus packed(3: 0) inz;

dcl-s success ind inz(*On);

dcl-s errMsg varchar(500) inz;

dcl-s refOrderNumber char(15) inz;

dcl-s refOrderStartPos int(10) inz;

dcl-s refOrderEnd int(10) inz;


*InLR = *On;


msgQHST = 'SNDMSG MSG(' + q + '---> Version 1.0 <---' + q + ') TOMSGQ(QHST)';

SysCmd(msgQHST);


uri = %str(getenv('REQUEST_URI'));


msgQHST = 'SNDMSG MSG(' + q + %Trim(uri) + q + ') TOMSGQ(QHST)';

SysCmd(msgQHST);


refOrderStartPos = %Scan('/ORDERS/': uri) + %len('/ORDERS/');

refOrderNumber = %Trim(%SubSt(uri: refOrderStartPos));


msgQHST = 'SNDMSG MSG(' + q + 'refOrderNumber: ' +

%Trim(refOrderNumber) + q + ') TOMSGQ(QHST)';

SysCmd(msgQHST);


msgQHST = 'SNDMSG MSG(' + q + 'Building data field' + q + ') TOMSGQ(QHST)';

SysCmd(msgQHST);


data = 'Status: 500 Invalid URI' + CRLF

+ 'Content-type: text/json' + CRLF + CRLF

+ '{ "success": false, "errmsg": "Invalid URI!" }' + CRLF;


msgQHST = 'SNDMSG MSG(' + q + '--->Send Response data field: ' +

%Trim(data) + q + ') TOMSGQ(QHST)';

SysCmd(msgQHST);


QtmhWrStout(data: %len(%trim(data)): err);


msgQHST = 'SNDMSG MSG(' + q + 'err: ' +

%Trim(err) + q + ') TOMSGQ(QHST)';

SysCmd(msgQHST);


return;



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.