Using tRestclient component to do HTTP Post request

One Star

Using tRestclient component to do HTTP Post request

Hi,
I have a PHP script which does HTTP post request to get data from external API service . I am trying to migrate that script to Talend using tRestClient to do a http post request with content type as JSON. Script has following callobject
$callobj = array(
'method' => $method_name,
'params' => array( 'partner_id' => $partner_id,
'tms' => $tms,
'sig' => $sig,
'date' => 'yyyy-mm-dd', // Only one date allowed per api call
'attribution' => 'conversion', // 'conversion' or 'click', determines whether to filter date by view/click or by conversion
'timezone' => 'UTC',
'fields' => array( 'site_id', 'type', 'name', 'conversion_datetime', 'action_type','client_user_id'),
)
);
In tRestClient component I have set up following based on above code snippet
I have given the url, HTTP Method - POST, Content Type -> JSON, Accept_type -> JSON
In query parameters
"method" - "method_name"
"params" -"partner_id=X$partner_id,tms=$tms,sig=$sig,date=yyyy-mm-dd,attribution=click,timezone=PST,fields=site_id,metrics=fbspend"
But it is not working. Is this kind of POST request supported in Talend? Is there way to pass this parameters? Can you please help me?
Thanks,
Gowri
Four Stars

Re: Using tRestclient component to do HTTP Post request

Hi Gauri,
Try using tFileFetch component.... I used this to fetch data from web services...
Use Post method and provide all the parameter values
provide your api URL at URI, provide destination directory for received response... also provide file name...
This may help
Thanks
Vaibhav
One Star

Re: Using tRestclient component to do HTTP Post request

Hi.
Thanks Vaibhav. I have to sent a request to a service which will give a JSON response. If it is a file, TfileFetch component will be useful. In my case, it will be response for a request.