Page 1 of 1

RESTful web service request headers

PostPosted: Thu Mar 21, 2019 2:33 pm
by steve1376656734
Hi,

Is there any way to access the headers from the request in a Servoy RESTful web service. The client will send an API token as a header but I cannot see any way to get the value of this token in the ws_xxxx routines. Is this possible?

Thanks
Steve

Re: RESTful web service request headers

PostPosted: Thu Mar 21, 2019 7:11 pm
by mboegem
Hi Steve,

Although I never used it (I always use the velocity plugin for my API's), I guess it should be possible.

The plugin has a getRequest() function which returns the current running request.

So, this should return you the Authorization header:
Code: Select all
plugins.rest_ws.getRequest().getHeader('Authorization')



Hope this helps

Re: RESTful web service request headers

PostPosted: Thu Mar 21, 2019 8:20 pm
by steve1376656734
Marc you are a star! Just tried it and it works exactly as I want. I can access any of the headers using plugins.rest_ws.getRequest().getHeader("KeyName")

I had completely missed the fact that there was a rest_ws plugin and this is not mentioned at all on the Servoy Wiki for RESTful services.

If you are at ServoyWorld this year then I owe you a beer.

Thanks
Steve

Re: RESTful web service request headers

PostPosted: Fri Mar 22, 2019 10:46 am
by rgansevles
Steve,

There was a inconspicuous link in the docs to the client plugin.
I have added a section to describe the client side a bit more explicit.

See https://wiki.servoy.com/display/DOCS/RE ... b+Services

Rob

Re: RESTful web service request headers

PostPosted: Fri Mar 22, 2019 11:06 am
by mboegem
steve1376656734 wrote:If you are at ServoyWorld this year


It's al booked, see you there :wink: