Five Stars

How to make Post request using tRestrequest component

Hi,

 

I have one API and url is looks like this "https://mycontent.com/v2/tokens"

 

And when I use this postman I use below configuration

 

Method: POST

 

Headers

Content-Type: application/x-www-form-urlencoded

 

Body:

Check option: x-www-form-urlencoded

 

Parameters added

Username:abc

Password:abc

Department:Finance

 

It gives me XML response.

 

I have seen all posts on Talend forum but no one could help me to setup like this.

 

May I know please how can I set up these configuration in trestrequest and get a response ?

 

Thanks

5 REPLIES
Seventeen Stars

Re: How to make Post request using tRestrequest component

tRESTRequest does not respond, the response comes from tRESTResponse.

You need always both components!

You can have more than one tRESTResponse but only one is allowed to answer per request.

This way you can send different responses (normal output or error response but you could also use only one tRESTResponse and handle all different responses with only this one. 

Five Stars

Re: How to make Post request using tRestrequest component

Hi Jan

 

Thanks for the response.

 

Actually my API response with HTTPS only and it gives proper response when I test with Postman. But when I do with HTTPS in trestrequest it shows error like this 

 

"Caused by: java.lang.RuntimeException: Protocol mismatch for port -1: engine's protocol is http, the url protocol is https"

 

Here is my configuration but still gets error, Could you please have a look where am doing wrong ?

 

restrequest.pngrequestschema.png

 

And When I do with HTTP only I'm getting error like this

 

"Cannot assign requested address: bind
java.net.BindException: Cannot assign requested address: bind"

 

Dont know why but its works from Postman. And where I need to set content-type in tRestrequest Jan ?

 

May I know please how can I make it work ?

 

 

Seventeen Stars

Re: How to make Post request using tRestrequest component

Of course. This is correct. You have to activate https in the runtime container or you have to add a forward proxy which enforces encryption.

Five Stars

Re: How to make Post request using tRestrequest component

Hi Jan

Its working absolutely fine with tRest component with POST.  Then why its not working with tRestrequest ?

 

But Like you said "You have to activate https in the runtime container or you have to add a forward proxy which enforces encryption"

 

Where I need to look for to enable these setting ? Is it in Talend or somewhere else ? Because like I said my API gives response with HTTPS in POSTMAN, so where I'm missing ?

Five Stars

Re: How to make Post request using tRestrequest component

Any suggestion please ? Or its a BUG ?