Thank you both for your responses. I totally agree on using JSON. I
explained the "separation of concern" to the person who takes the final
call on design before posting the question here but he wanted to use some
of the features from "Content Management" and wanted to send HTML. So I
wanted to check if there is any such possibility in Ofbiz Rest.
On Sun, Feb 20, 2022 at 5:14 PM Michael Brohl
wrote:
> Hi,
>
> the REST-API ist designed to either automatically expose standard OFBiz
> services through the export configuration or configure an API through
> the special rest configuration (also using services underneath). It is
> automatically reading body or url parameters, providing them to the
> underlying service and returns the service results in a structured
> format which is currently only JSON.
>
> As Carsten mentioned, for a REST API it is common to have structured
> input/output like JSON or the less used XML format. The REST-API plugin
> currently supports JSON. We are working on enhancing the plugin (see
> [1]) but I don't expect to have it support HTML.
>
> If you want to return HTML, you can just go with the standard way of
> http requests, getting data and rendering through the Freemarker
> template engine.
>
> I agree with Carsten, it sounds like you should use the REST-API as-is
> and render the JSON results using some templating in your consuming client.
>
> Best regards,
>
> Michael Brohl
>
> ecomify GmbH - www.ecomify.de
>
> [1] https://issues.apache.org/jira/browse/OFBIZ-11328
>
> Am 19.02.22 um 07:36 schrieb Carsten Schinzer:
> > Hi again,
> >
> >
> > I wonder why a REST API Service would be expected to return HTML. Isn’t
> the
> > client of the REST API responsible to render the returned JSON?
> >
> > If you would expect XML for example, ok. But HTML? Hum.
> > Maybe it is worth to read the Wikipedia article on REST API and
> understand
> > that your idea rather counters its basic idea of separating concerns.
> > https://en.wikipedia.org/wiki/Representational_state_transfer
> >
> > You might want to review your “scenario” and consider a HTML rendering
> step
> > on your side after retrieving the relevant data from the API?
> >
> > Warm regards
> >
> >
> > Carsten
> >
> >
> > Altafhusen Makandar schrieb am Fr. 18. Feb.
> 2022
> > um 11:06:
> >
> >> Thank you for your response. This is a generic question related to the
> >> request and response object type in ofbiz rest API. In my understanding,
> >> the rest API currently supports the request and response object type as
> >> JSON. I've scenario where I want to return a HTML data and not JSON
> object.
> >> Similarly, there may be other type of object that I may receive or
> return.
> >> So I wanted to check if the feature to receive or return other types
> other
> >> than JSON is available. If it's available then a small code snippet of
> it's
> >> usage would be helpful to me. It would be great if I get some
> information
> >> on this. Thank you.
> >>
> >> On Fri, Feb 18, 2022, 09:40 Carsten Schinzer <
> >> cars...@dcs-verkaufssysteme.de>
> >> wrote:
> >>
> >>> Hello,
> >>>
> >>>
> >>> I am not really sure, your question is clear to everybody. I would
> >> wonder:
> >>> Is this a generic question?
> >>> I ask, because "application/json" indicates that a structured content
> >> with
> >>> key-value pairs (potentially matching a given schema) will be returned
> >>> while the other content types you are asking for are (content-wise) not
> >>> structured in that sense: text/html, text/plain, multipart/*.
> >>> Are you looking for something concrete here?
> >>>
> >>> Maybe it helps to describe your use case a bit more.
> >>> Warm regards
> >>>
> >>>
> >>> Carsten
> >>>
> >>>
> >>>
> >>> ---
> >>>
> >>>
> >>> Dr. Carsten Schinzer
> >>>
> >>> *Inhaber*
> >>>
> >>>
> >>> t +49 89 88569642 | f +49 89 99964059 | m +49 159 05269462
> >>>
> >>> DCS Verkaufssysteme
> >>>
> >>> Gerner Str. 27 | 80638 München | Germany
> >>>
> >>>
> >>> Am Do., 17. Feb. 2022 um 22:55 Uhr schrieb Altafhusen Makandar <
> >>> altafhusen...@gmail.com>:
> >>>
> Can someone please provide some information on this?
>
> On Thu, Feb 17, 2022, 10:43 Altafhusen Makandar <
> >> altafhusen...@gmail.com
> wrote:
>
> > Hi,
> >
> > I am using the rest API feature of the ofbiz and I found the
> > "application/json".as the content-type. Do we have a feature for
> >> other
> > content types like text/html, text/plain, multipart/* and so on?
> >
> > Regards,
> > Altaf.
> >
>