One Star

[resolved] Get header information from tRestRequest

Hello,
I am trying to developp a REST web service for a project.
For the need of the project, I would like to know if it's possible to get the header of the REST request ? And how ?
Thank's in advance for your answer.
1 ACCEPTED SOLUTION

Accepted Solutions
Employee

Re: [resolved] Get header information from tRestRequest

Works for me OK. I have a simple job which accepts the XMl payload via POST, passes it to tLogRow and echoes back via tRESTResponse.
tRESTRequest schema is exactly the same as in your example, except that I did not put a default value.
Doing:
"curl -X "Content-Type: application/xml" -H "EndpointNm: test" -d "<hello/>" http://localhost:8088"
results in tLogRow reporting:
<?xml version="1.0" encoding="UTF-8"?>
<hello/>|test
Cheers, Sergey
6 REPLIES
Employee

Re: [resolved] Get header information from tRestRequest

Hi,
you can access individual headers by adding parameters in a schema editor and adding a 'header' to the Comment field.
tRESTRequest also sets the map of all the headers it receives as a context var, I don't have a studio opened right now but it will be easy to spot.
Going the schema editor route is the simplest approach
HTH, Sergey
One Star

Re: [resolved] Get header information from tRestRequest

sberyozkin,

I also have this problem and tried to add header in the Comment section like said in the documentation.
Any idea of what I'm doing wrong?

Here are my screenshots:
Employee

Re: [resolved] Get header information from tRestRequest

Works for me OK. I have a simple job which accepts the XMl payload via POST, passes it to tLogRow and echoes back via tRESTResponse.
tRESTRequest schema is exactly the same as in your example, except that I did not put a default value.
Doing:
"curl -X "Content-Type: application/xml" -H "EndpointNm: test" -d "<hello/>" http://localhost:8088"
results in tLogRow reporting:
<?xml version="1.0" encoding="UTF-8"?>
<hello/>|test
Cheers, Sergey
One Star

Re: [resolved] Get header information from tRestRequest

Damn I tried it out today and it magically worked Smiley Happy
Thanks sberyoskin , even if you didn't do much ^^
One Star

Re: [resolved] Get header information from tRestRequest

It works fine for me too !
Thank you so much.
Four Stars

Re: [resolved] Get header information from tRestRequest

I am not getting any output while I tried to print EndpointNm in tJavaFlex. I need to get username and password from the header like http basic  authentication.can anyone please suggest how can I get that.
I am attaching screen shots of error and my job.