RESTful web service request headers

The forum to discuss the Headless version of Servoy. Web, Java and Servlet development questions can all be posted here.

RESTful web service request headers

Postby steve1376656734 » Thu Mar 21, 2019 2:33 pm

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
Steve
SAN Developer
There are 10 types of people in the world - those that understand binary and those that don't
steve1376656734
 
Posts: 221
Joined: Fri Aug 16, 2013 2:38 pm
Location: Lanzarote

Re: RESTful web service request headers

Postby mboegem » Thu Mar 21, 2019 7:11 pm

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
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1499
Joined: Sun Oct 14, 2007 1:34 pm
Location: Hoofddorp, The Netherlands

Re: RESTful web service request headers

Postby steve1376656734 » Thu Mar 21, 2019 8:20 pm

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
Steve
SAN Developer
There are 10 types of people in the world - those that understand binary and those that don't
steve1376656734
 
Posts: 221
Joined: Fri Aug 16, 2013 2:38 pm
Location: Lanzarote

Re: RESTful web service request headers

Postby rgansevles » Fri Mar 22, 2019 10:46 am

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
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1889
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: RESTful web service request headers

Postby mboegem » Fri Mar 22, 2019 11:06 am

steve1376656734 wrote:If you are at ServoyWorld this year


It's al booked, see you there :wink:
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1499
Joined: Sun Oct 14, 2007 1:34 pm
Location: Hoofddorp, The Netherlands


Return to Servoy Headless Client

Who is online

Users browsing this forum: No registered users and 0 guests