× 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've only done JSON in C#.net so maybe it does something automagically that
the iSeries has to do manually. So, this might be a stupid question.

When I have dealt with JSON, the " Content-type: text/json" is part of the
headers and not part of the data. So, is it possible that the "Status: 500
Invalid URI??Content-type: text/json????" part is confusing it because it is
not JSON formatted.

-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxx> On Behalf Of Bradley
Stone
Sent: Friday, July 27, 2018 3:52 PM
To: Midrange Systems Technical Discussion <midrange-l@xxxxxxxxxxxx>
Subject: Re: REST service not sending JSON response body

If they do, then that's not the problem. Just throwing ideas out there,
Jon. Something is wrong with the code.

Bradley V. Stone
www.bvstools.com
GreenTools for G Suite/Google Apps <https://www.bvstools.com/g4g.html>:
Easy to use interfaces for GMail, Google Drive, Calendar, Contacts and Cloud
Print! <\body> <\html>

On Fri, Jul 27, 2018 at 2:34 PM Jon Paris <jon.paris@xxxxxxxxxxxxxx> wrote:

Those two protos produce identical results Brad so how can it help?


Jon Paris

www.partner400.com
www.SystemiDeveloper.com

On Jul 27, 2018, at 3:03 PM, Bradley Stone <bvstone@xxxxxxxxx> wrote:

I'd look into your definition for QtmhWrStout, then.

dcl-pr QtmhWrStout extproc('QtmhWrStout');
dtaVar char(65535) options(*varsize) const;
dtaCarLen int(10) const;
errorCode char(8000) options(*varsize); end-pr;

vs

dcl-pr QtmhWrStout extproc('QtmhWrStout');
dtaVar pointer;
dtaCarLen int(10) const;
errorCode char(8000) options(*varsize); end-pr;


and use:
QtmhWrstout( %addr(data) : %len(%trimr(data) : errorCode );
vs
QtmhWrStout(data: %len(%trim(data)): err);

I would also debug and right before you call QtmhWrStout debug the value
of
data and it's length (which you'd need a variable for). My bet is it's
either one or the other or both of those things.



On Fri, Jul 27, 2018 at 9:20 AM Rich Dotson <rich_dotson@xxxxxxxxxxx>
wrote:

Thanks for the response Bradley.


1. Sent my URL through Postman:
* Body: Nothing was returned
* Header: content-language -> en-US

content-length --> 0

date --> Fri, 27 Jul 2018 14:09:41 GMT

x-powered-by --> IBM i


2. The JSON that will be returned is already being generated using
YAJL.
It is currently being written to the IFS and picked up by a network
scheduled job. Once I get this REST pgm working I was going to
capture
that JSON and send it back as the response.




________________________________
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxx> on behalf of Bradley
Stone <bvstone@xxxxxxxxx>
Sent: Friday, July 27, 2018 9:46 AM
To: Midrange Systems Technical Discussion
Subject: Re: REST service not sending JSON response body

A couple things.

Can you send a response from Postman or Chrome debugger to see
everything
being returned?

2nd, I would strongly suggest you use something like Scott Klements
YAJL
for this instead of calling the raw APIs, especially for building the
JSON. There is also a function in YAJL that will write out your JSON
with
headers.

Using CGIDEV2 or eRPGSDK will also make things easier, such as reason
responses or any data parms passed in through a GET or POST.

I understand it's just a proof of concept. :)

Bradley V. Stone
www.bvstools.com<http://www.bvstools.com>
GreenTools for G Suite/Google Apps <https://www.bvstools.com/g4g.html>:
Easy to use interfaces for GMail, Google Drive, Calendar, Contacts and
Cloud Print! <\body> <\html>

On Fri, Jul 27, 2018 at 7:20 AM Rich Dotson <rich_dotson@xxxxxxxxxxx>
wrote:



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;


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD



Bradley V. Stone
www.bvstools.com
MAILTOOL Benefit #2 <https://www.bvstools.com/mailtool.html>: The
ability
to specify a "From" and/or "Reply To" email address!
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate
link: http://amzn.to/2dEadiD


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

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.