× 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.



Snippet for ouput media type as XML and JSON

Columns . . . : 1 100
Browse NEWCM/QRPGLESRC

SEU==>
HEDQTRGET

FMT ** ...+... 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6
...+... 7 ...+... 8 ...+... 9 ...+... 0

*************** Beginning of data
***************************************************************************************


0001.00
**free


0002.00 ctl-opt OPTION(*SRCSTMT : *NODEBUGIO :
*SHOWCPY);

0007.00


0008.00 dcl-Pr main
extpgm('HEDQTRGET');

0009.00 *n
Char(1000);


0010.00 *n
Char(16000000);


0011.00
end-Pr;


0012.00 dcl-Pi main
;


0013.00 p
Char(1000);


0014.00 dataOut
Char(16000000);

0015.00 end-Pi;


0016.00 /include
IUTILITYP,IUTILITY


0017.00 /include
UTILITYP,UTILITY


0018.00 /include
APCJSONP,HEADQTRS

0019.00


0020.00 dcl-s routeParameters1
varChar(1000);

0021.00 dcl-s JSONOut1
varChar(16000000);


0022.00


0023.00 routeParameters1 = '?idpk=' +
p;
190521

0025.00 callp
json_get_Headquarters(routeParameters1:JSONOut1);
190521

0026.00


0027.00 dataout = JSONOut1;


0028.00


0029.00 *inlr =
*on;




F3=Exit F5=Refresh F9=Retrieve F10=Cursor F11=Toggle
F12=Cancel

F16=Repeat find F24=More
keys







Value of JSONOUT1 in debug




EVAL
JSONOut1

JSONOUT1
=


....5...10...15...20...25...30...35...40...45...50...55...60

1 '{"headquarterNumber":800000000,"headquarterName":"TEST8
'

61 '
","headquarterAddr'

121 'essLine1":"ADR8
'

181 ' ","headquarterAddressLine2":"ADDRESS2
'

241 '
","headquarterAddressLine3":"ADDRESS'

301 '3 ","headquarterC”};



Response in Postman

{

"headquarterNumber": 800000000,

"headquarterName": "TEST8
",

"headquarterAddressLine1":
"ADR8 ",

"headquarterAddressLine2":
"ADDRESS2 ",

"headquarterAddressLine3":
"ADDRESS3 ",

}



Header info ( Content typ-Application/xml)

*Date →*Thu, 23 May 2019 16:55:53 GMT

*Server →*Apache

*X-Powered-By →*IBM i

*Content-Length →*1156

*Access-Control-Allow-Origin →**

*Access-Control-Allow-Headers →*origin, x-requested-with, content-type

*Access-Control-Allow-Methods →*PUT, GET, POST, DELETE, OPTIONS

*Connection →*close

*Content-Type →*application/xml

*Content-Language →*en-US





On Thu, May 23, 2019 at 2:16 PM anshul narang <narang.anshul@xxxxxxxxx>
wrote:

Hi Peter/Nadir

Thank you for your email. I am trying to set up the webservices to return
response in JSON format only.

This can be done by putting http header as application /json or setting
the output media as JSON only. I have tried both scenarios.

Please find the document attached.

Thank you !

On Thu, May 23, 2019 at 12:52 PM Peter Dow <petercdow@xxxxxxxxx> wrote:

When you say "If I set the allow output media to (Json and XML)", do you
mean when you deploy the webserver?

If yes, then the client controls which format the response is in by
sending an http header of

Accept:application/json
or Accept:application/xml

--
*Peter Dow* /
Dow Software Services, Inc.
909 793-9050
petercdow@xxxxxxxxx <mailto:petercdow@xxxxxxxxx>
pdow@xxxxxxxxxxxxxx <mailto:pdow@xxxxxxxxxxxxxx>

/
On 5/22/2019 3:44 AM, anshul narang wrote:
Hi All

I have been trying to deploy restful services using IBM web admin for
I. I
have come acros peculiar situation with JSON.

I have set the allow output media as JSON . In the response I get the
\(escape characters ) with RAW as JSON.


- {\"headquarterNumber\":37 }


If I set the allow output media to (Json and XML) . The output is like
with
RAW as XML as below.


- {"headquarterNumber":37}


I have set headers as application json as well. It doenst resolve the
issue.

Please help me on this issue





---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
list
To post a message email: WEB400@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.



--

Thank You

Anshul Narang
715-921-4968




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.