json response

One Star

json response

Hi,
i have to fetch json response from url using cookie concept.
I have tried with using only trestclient step there is no cookie option is available and later on i tried with tfilefetch component to use the cookie concept it is giving 200 as a response but i am not able to get any response from the tfilefetch?
1) I haved logged in using tfilefetch component using tfilefetch with cookie concept i,e giving 200 as response code.
2) I am trying to get json response from the one more url using tfilefetch component it is giving as 200 response code but in that file only html content is generated instead of response code using existing cookies which i have used it in step 1.
Output log from two tfilefetch components is
Status Line: HTTP/1.1 200 OK
*** Response Header ***
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=ISO-8859-1
Content-Language: en-US
Content-Length: 3072
Vary: Accept-Encoding
Date: Thu, 09 Jan 2014 13:34:02 GMT
Status Line: HTTP/1.1 200 OK
*** Response Header ***
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=ISO-8859-1
Content-Language: en-US
Content-Length: 3072
Vary: Accept-Encoding
Date: Thu, 09 Jan 2014 13:34:07 GMT
How can we do it ? Is there any work around to do this.. Please give ur suggestions.
Community Manager

Re: json response

Hi
tFileFetch is used to download a file with http or ftp procotol to local machine, this component don't have a schema and it do not returns a response, this component is always used alone, it has no output. If you want to call a rest web service, you should use the tRestClient or tRest component.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: json response

If i am using trestclient i cant use the cookie concept..
Basically i have to use cookie concept for the login once that is done i wanted to use that cookie variable to another job
So how can i use that using trest client or trest ?
Community Manager

Re: json response

There is no 'save or read cookie' option on tRestClient component, so you can't use the rest component to call the web service in this case. I would suggest you to report a feature issue on our bugtracker to inform our developers, they will investigate this issue further.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: json response

I need exactly the same functionality and am bummed not to find it here. Let me know if you post a request in the system and I'll vote it up.
One Star

Re: json response

I have done it using tRest Component instead of tRestClinet step.
One Star

Re: json response

I don't see the "read cookie" option on the tRest nor the tRestClient component. Could you elaborate on how you got this to work?
One Star

Re: json response

What is ur exact requirement can you elaborate it?
One Star

Re: json response

Hi,
I need to send users data to intercom by using intercom api.
I designed a job having a flow of tFileInputJSON ->tXMLMap -> tRestClient -> tLogRow.
I got response code 200 ok but users are not sending at intercom.
My output is -
Starting job Intermediate at 09:57 21/10/2015.
connecting to socket on port 3389
connected
: org.apache.cxf.interceptor.LoggingOutInterceptor - Outbound Message
---------------------------
ID: 1
Address:
Http-Method: POST
Content-Type: application/json
Headers: {Content-Type=, Accept=, Authorization=}
Payload: {"items":{"user_id":"swati1036","email":"w@serenity.io","name":"Serenity Washburne","signed_up_at":1392731325,"last_seen_ip":"1.2.3.6","last_seen_user_agent":"Mozilla\/5.0(Macintosh; Intel Mac OS X 10.9"}}
--------------------------------------
: org.apache.cxf.interceptor.LoggingInInterceptor - Inbound Message
----------------------------
ID: 1
Response-Code: 200
Encoding: UTF-8
Content-Type: application/json; charset=utf-8
Headers: {Cache-Control=, connection=, Content-Length=, content-type=, Date=, ETag=, Server=, Status=, Strict-Transport-Security=, Vary=, X-Content-Type-Options=, X-Frame-Options=, X-Intercom-Version=, X-Intercomrade=, X-RateLimit-Limit=, X-RateLimit-Remaining=, X-RateLimit-Reset=, X-Request-Id=, X-Runtime=, X-XSS-Protection=}
Payload: {"app_id":"p4lt44zd","id":"job_f220bbc4_77ea_11e5_9d9a_25b12484386c","created_at":1445428667,"completed_at":null,"closing_at":1445429567,"updated_at":1445428667,"name":"api_bulk_job","state":"running","links":{"error":"","self":""}}
--------------------------------------
statusCode: 200|body: |string: {"app_id":"p4lt44zd","id":"job_f220bbc4_77ea_11e5_9d9a_25b12484386c","created_at":1445428667,"completed_at":null,"closing_at":1445429567,"updated_at":1445428667,"name":"api_bulk_job","state":"running","links":{"error":"","self":""}}
disconnected
Job Intermediate ended at 09:57 21/10/2015.
One Star

Re: json response

Hi,
I posted my issue at 21 October but still have no reply on it.
Can anybody help me on this?
Community Manager

Re: json response

Payload: {"items":{"user_id":"swati1036","email":"w@serenity.io","name":"Serenity Washburne","signed_up_at":1392731325,"last_seen_ip":"1.2.3.6","last_seen_user_agent":"Mozilla\/5.0(Macintosh; Intel Mac OS X 10.9"}}

This is the payload request send from tRestClient, is it the right data what your server expects?
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: json response

same json data is sending by the chrome Rest Client and it was working fine so i think intercom is accepting this data.
One Star

Re: json response

The only difference of chrome Rest client and tRestClient is that - in tXMLmap, i have to fetch all fields in the item tag.
One Star

Re: json response

image is this - 
One Star

Re: json response

image is this - 
Six Stars

Re: json response

Good day
If your webapi accept Json, you should use the field : String and not the field : body in your txmlmap.
If your webapi accept xml then your current solution is perfect.
Please show me the configuration of the tRestClient
Best regards,
Alfonso Borre
One Star

Re: json response

Hi,
Thanks for the reply.
But, i am using tRest for sending users and have success in fixed json data.
I have to send users dynamically, then i am using this flow - 
tMSSqlOutput (get one table)
->tJavaRow set context (context.c_user_id = input_row.user_id;
                                   context.c_name = input_row.name;
                                   context.c_email = input_row.EmailSmiley Wink
->tRest 
(Headers - "Accept"- "application/json"
"Content-Type"-"application/json"
"Authorization"-"Basic cDRsdDQ0emQ6ZTQ1ZjczZDYwOWRiMGUxNzcwZjI4MDgxZDcxMGM5ODBkZDg4MDIyMA=="
HTTP Body -
"{
  \"user_id\":+context.c_user_id+,
  \"email\": +context.c_email+,
  \"name\": +context.c_name+
}"
)
Intercom is not accepting single quotes so here i am using this \" in place of single quote. So not able to pass context value this code is always send label as it is.
Can you please help me.
Thanks in advance.
One Star

Re: json response

And can you please elaborate this line "If your webapi accept Json, you should use the field : String and not the field : body in your txmlmap"?
or do you have example on it because intercom is accepting& content-Type is json data.
I can also work to do this.
Thanks.
One Star

Re: json response

Hi ingenioso,
I need a example for txmlmap for json data because now i am sending my users data in body field and string field is blank. body tag is always returning xml data but intercom needs json data so how can i achieve this?
Please help me on this.
Thanks.