Page 1 of 1

Change content-type for WAM

Posted: Mon May 11, 2020 9:09 pm
by kno_dk
I have a question regarding WAM. is it possible to change the content-type and charset to “application/json; charset=UTF-8” from the original “text/html; charset=ISO-8859-1”?

If I change the response to *json then it sends the “application/json; charset=UTF-8” but I would like to build the respons in the xsl myself so I have to have the response set to *default.

/klaus

Re: Change content-type for WAM

Posted: Tue May 12, 2020 10:27 am
by AbelS
If you want to prepare your own custom JSON (but not use web services), you can send the response as a CLOB. With a CLOB, you set the response headers yourself.

HTH
Abel

Re: Change content-type for WAM

Posted: Tue May 12, 2020 7:07 pm
by kno_dk
Hi Abel.

Should I then set the resonse as *Default or JSON in the WAM?
If it is default then I would still have the content-type text/html, and if it is JSON then I have a lot of json describing the wam routine in the respons.
Do you have an example?

/klaus

Re: Change content-type for WAM

Posted: Wed May 13, 2020 9:12 am
by AbelS
HI Klaus

Here is the topic about LOBs and how to create them and set custom HTTP headers:

https://docs.lansa.com/14/en/lansa087/i ... s%7C_____0

Abel

Re: Change content-type for WAM

Posted: Wed May 13, 2020 7:54 pm
by kno_dk
Hi

I have now tried it like in the manual. if I change the content type to application/json I get this result:

�����������z������G

I have tried to add charset := 'UTF-8' but same result.

If i don't change the Contenttype there is no problem. But I need to have the contenttype to application/json.

this is running on an IBM I.

Any suggestion?

/klaus

Re: Change content-type for WAM

Posted: Thu May 14, 2020 9:40 am
by AbelS
If you use content-type application/* then the runtime won't do any transcoding (that is, it handles the content as binary). If you want to use application/json, then you need to create your BLOB content with the target encoding (ISO-8859-1 or UTF-8 . Note that if you are on IBM i, any text content in native encoding will be in EBCDIC.

Abel

Re: Change content-type for WAM

Posted: Thu May 14, 2020 5:46 pm
by kno_dk
Hi Abel.

So what you are saying is that this could not be done on an IBM I? or is there a way around this conversion issue?

If I define thr response as JSON then it is convertet correct, but then I am not able to control the output as much as I want

/klaus

Re: Change content-type for WAM

Posted: Fri May 15, 2020 8:42 am
by soa
I think you can create a temporary ifs file with the encoding you want and write your content to it then use that file as the http response. Then the temporary file can be automatically deleted.