Consuming Rest service with custom media type

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Consuming Rest service with custom media type

Geert
Hi there,

we prepopulate some input fields via a rest service. Our Orbeon version is 2016.1.
This all works just fine when the media type is 'application/json'.

The problem is that we have to incorporate some service where the media type is custom.
I worked around this problem by developing a proxy service that alters the header and changes the media type to 'application/json'.

I know a lot is possible when you jump into the generated xforms source code. But are there any plans to allow the possibility to specify a custom media type in the form builder? In the end, it is all json. :-)

Regards,
Geert
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Consuming Rest service with custom media type

Alessandro  Vernet
Administrator
Hi Geert,

In 2016.1 we added the support for all the media types of the form `application/*+json`, like `application/csvm+json`. But I imagine that your custom media type is different, since you're using 2016.1, correct? Would it make sense for you to change it to something of the form `application/*+json`, by any chance? (If not, there is no "XForms magic" ;) right now that allows you tell an XForms submission that the result must be interpreted as JSON, irrelevant of the media type.

https://github.com/orbeon/orbeon-forms/issues/3101

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Consuming Rest service with custom media type

Geert
Hi Alessandro,

here you can find a few samples of those custom media type.
As you can see they are all of the form  application/*+json.

So if I understand you correctly, this should work?

application/vnd.be.securex.genservices.securityservices.customers.model.webuserv1+json
application/vnd.be.securex.cbservices.referencecodeservice.country.model.countryv1+json

I've attached a screenshot of a small test. As you can see the "Test Results" tab in the HTTP Service Editor turns red but the response body is actually available.

Using an action to prepopulate a form field does not work in this case.


Regards,
Geert

ServiceCallCustomMediaType.png
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Consuming Rest service with custom media type

Alessandro  Vernet
Administrator
Hi Geert,

Ah, my apologies: this feature is new not in 2016.1 but 2017.1, just released yesterday (!), which explains why this isn't working for you. Would you be able to try this with 2017.1?

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Consuming Rest service with custom media type

Geert
Hi Alessandro,

I've tested it with version 2017.1 and indeed, it works as a charm.

Kind regards
Geert
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Consuming Rest service with custom media type

Alessandro  Vernet
Administrator
Excellent Geert, and thank you for the confirmation.

Alex
--
Follow Orbeon on Twitter: @orbeon
Follow me on Twitter: @avernet
Loading...