<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: tRest does not return a body when getting a 400 error in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304028#M75845</link>
    <description>I had the same problem. I found the solution to getting (at least) the http error message: 
&lt;BR /&gt; 
&lt;PRE&gt;org.apache.http.impl.EnglishReasonPhraseCatalog.INSTANCE.getReason(row27.ERROR_CODE,null)&lt;/PRE&gt; 
&lt;BR /&gt;(where 
&lt;B&gt;row27&lt;/B&gt; is the row coming out of the 
&lt;B&gt;tRest&lt;/B&gt; component) 
&lt;BR /&gt; 
&lt;BR /&gt;Concatenating the ERROR_CODE with the result of the operation above, it looks like this: 
&lt;I&gt;'401-Unauthorized'&lt;/I&gt;. So now it is a bit easier to understand in my 
&lt;B&gt;tDie&lt;/B&gt;. 
&lt;BR /&gt;However, as others mentioned, I cannot get the more specific error information returned by the WS that I'm using, because the body comes back empty. 
&lt;BR /&gt;Note: you might need to download and add the 
&lt;B&gt;HttpCore&lt;/B&gt; Apache library to your 
&lt;B&gt;/talend_installation_path/configuration/lib/java&lt;/B&gt;. And you might also have to use a 
&lt;B&gt;tLibrary&lt;/B&gt; load to load it in your job before calling it.</description>
    <pubDate>Fri, 24 Jun 2016 21:45:06 GMT</pubDate>
    <dc:creator>_AnonymousUser</dc:creator>
    <dc:date>2016-06-24T21:45:06Z</dc:date>
    <item>
      <title>tRest does not return a body when getting a 400 error</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304020#M75837</link>
      <description>Hi,&lt;BR /&gt;I'm using talend to call some Rest webservices with the tRest component. I log the response body and http status code.&lt;BR /&gt;It works fine when I get 2XX http codes, but when my WS returns a 4XX status code, the tRest always returns a null value for the body. &lt;BR /&gt;However, the body contains a message explaining why an error occured, so I need to retrieve this body even if I get a 4XX error code. &lt;BR /&gt;Is this a bug in the tRest component ? &lt;BR /&gt;Thanks.</description>
      <pubDate>Thu, 25 Apr 2013 11:35:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304020#M75837</guid>
      <dc:creator>_AnonymousUser</dc:creator>
      <dc:date>2013-04-25T11:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: tRest does not return a body when getting a 400 error</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304021#M75838</link>
      <description>Hi
&lt;BR /&gt;What's the result if you call the rest ws in browser? Do you get some message or null if it returns a 4xx status code? I think it is the same result in Talend or browser.
&lt;BR /&gt;Shong</description>
      <pubDate>Fri, 26 Apr 2013 02:41:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304021#M75838</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-04-26T02:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: tRest does not return a body when getting a 400 error</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304022#M75839</link>
      <description>Hi, 
&lt;BR /&gt;When I call the ws in browser, or with an http rest plugin, I get the expected error message. 
&lt;BR /&gt;I have inspected the tRest source code and I found that : 
&lt;BR /&gt;if(errorResponse_&amp;lt;%=cid%&amp;gt;!=null){ 
&lt;BR /&gt; &amp;lt;%=conn.getName() %&amp;gt;.ERROR_CODE = errorResponse_&amp;lt;%=cid%&amp;gt;.getStatus(); 
&lt;BR /&gt;} 
&lt;BR /&gt;else{ 
&lt;BR /&gt; &amp;lt;%=conn.getName() %&amp;gt;.Body = restResponse_&amp;lt;%=cid%&amp;gt;; 
&lt;BR /&gt;} 
&lt;BR /&gt;It seems that the component never parses the body response when getting an http error. 
&lt;BR /&gt;I tried to modify the component but it didn't work, so I have coded my own rest component that uses the java API and it works perfectly.</description>
      <pubDate>Fri, 26 Apr 2013 09:47:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304022#M75839</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-04-26T09:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: tRest does not return a body when getting a 400 error</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304023#M75840</link>
      <description>Just discovered this and its quite a nasty issue anyone know if there is a fix or work around? 
&lt;BR /&gt;https://www.talendforge.org/forum/img/members/69801/mini_null_rest_error_body.png.png 
&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009MEQJ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/129925iE550360E8C76ABBD/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009MEQJ.png" alt="0683p000009MEQJ.png" /&gt;&lt;/span&gt; 
&lt;BR /&gt;Cheers Andy</description>
      <pubDate>Thu, 04 Jun 2015 10:15:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304023#M75840</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-06-04T10:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: tRest does not return a body when getting a 400 error</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304024#M75841</link>
      <description>Hi moinerus 
&lt;BR /&gt;No changes about the response on tRestClient component, catch the error code and error message by using the error link. 
&lt;BR /&gt;tRestClient--response--tLogRow_1 
&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;--error---tLogRow_2 
&lt;BR /&gt;Best regards 
&lt;BR /&gt;Shong</description>
      <pubDate>Fri, 05 Jun 2015 12:21:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304024#M75841</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-06-05T12:21:34Z</dc:date>
    </item>
    <item>
      <title>Re: tRest does not return a body when getting a 400 error</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304025#M75842</link>
      <description>Hi Shong,
&lt;BR /&gt;Thanks for the response the component in question is tRest not tRestClient and doesn't have and error row output...
&lt;BR /&gt;Cheers M</description>
      <pubDate>Tue, 23 Jun 2015 13:00:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304025#M75842</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-06-23T13:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: tRest does not return a body when getting a 400 error</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304026#M75843</link>
      <description>Has anyone found a workaround for this?&lt;BR /&gt;The bug is in the tREST code:&lt;BR /&gt;&lt;PRE&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;row2 = new row2Struct();&lt;BR /&gt;				if (errorResponse_tREST_1 != null) {&lt;BR /&gt;					row2.ERROR_CODE = errorResponse_tREST_1.getStatus();&lt;BR /&gt;				} else {&lt;BR /&gt;					row2.Body = restResponse_tREST_1;&lt;BR /&gt;				}&lt;/PRE&gt;&lt;BR /&gt;This code only sets the body of the response if there was no error message.&lt;BR /&gt;The body should always be set, even if there was an error.</description>
      <pubDate>Wed, 17 Feb 2016 20:15:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304026#M75843</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-02-17T20:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: tRest does not return a body when getting a 400 error</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304027#M75844</link>
      <description>Here is the current Talend Code for tREST:&lt;BR /&gt;&lt;PRE&gt;String restResponse_tREST_1 = "";&lt;BR /&gt;try {&lt;BR /&gt;    restResponse_tREST_1 = restResource_tREST_1&lt;BR /&gt;            .post(String.class, context.json_request);&lt;BR /&gt;} catch (com.sun.jersey.api.client.UniformInterfaceException ue) {&lt;BR /&gt;    errorResponse_tREST_1 = ue.getResponse();&lt;BR /&gt;}&lt;BR /&gt;// for output&lt;BR /&gt;row2 = new row2Struct();&lt;BR /&gt;if (errorResponse_tREST_1 != null) {&lt;BR /&gt;    row2.ERROR_CODE = errorResponse_tREST_1.getStatus();&lt;BR /&gt;} else {&lt;BR /&gt;    row2.Body = restResponse_tREST_1;&lt;BR /&gt;}&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;It needs to be changed to something like the following:&lt;BR /&gt;&lt;PRE&gt;com.sun.jersey.api.client.ClientResponse restResponse_tREST_1;&lt;BR /&gt;try {&lt;BR /&gt;    restResponse_tREST_1 = restResource_tREST_1&lt;BR /&gt;            .post(com.sun.jersey.api.client.ClientResponse.class, context.json_request);&lt;BR /&gt;} catch (com.sun.jersey.api.client.UniformInterfaceException ue) {&lt;BR /&gt;    errorResponse_tREST_1 = ue.getResponse();&lt;BR /&gt;}&lt;BR /&gt;// for output&lt;BR /&gt;row2 = new row2Struct();&lt;BR /&gt;row2.Body = restResponse.getEntity(String.class));&lt;BR /&gt;row2.ERROR_CODE = restResponse.getStatus();&lt;BR /&gt;&lt;/PRE&gt;&lt;BR /&gt;Note that restResponse_tREST_1 was changed from a String to a Client Response.&lt;BR /&gt;Note that the first argument to .post was changed from String.class to ClientResponse.class&lt;BR /&gt;Note that row2.Body is now set to restResponse.getEntity(String.class)) and row2.ERROR_CODE is set to restResponse.getStatus()&lt;BR /&gt;With this code change, the response body becomes visible on errors.</description>
      <pubDate>Wed, 17 Feb 2016 20:53:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304027#M75844</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-02-17T20:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: tRest does not return a body when getting a 400 error</title>
      <link>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304028#M75845</link>
      <description>I had the same problem. I found the solution to getting (at least) the http error message: 
&lt;BR /&gt; 
&lt;PRE&gt;org.apache.http.impl.EnglishReasonPhraseCatalog.INSTANCE.getReason(row27.ERROR_CODE,null)&lt;/PRE&gt; 
&lt;BR /&gt;(where 
&lt;B&gt;row27&lt;/B&gt; is the row coming out of the 
&lt;B&gt;tRest&lt;/B&gt; component) 
&lt;BR /&gt; 
&lt;BR /&gt;Concatenating the ERROR_CODE with the result of the operation above, it looks like this: 
&lt;I&gt;'401-Unauthorized'&lt;/I&gt;. So now it is a bit easier to understand in my 
&lt;B&gt;tDie&lt;/B&gt;. 
&lt;BR /&gt;However, as others mentioned, I cannot get the more specific error information returned by the WS that I'm using, because the body comes back empty. 
&lt;BR /&gt;Note: you might need to download and add the 
&lt;B&gt;HttpCore&lt;/B&gt; Apache library to your 
&lt;B&gt;/talend_installation_path/configuration/lib/java&lt;/B&gt;. And you might also have to use a 
&lt;B&gt;tLibrary&lt;/B&gt; load to load it in your job before calling it.</description>
      <pubDate>Fri, 24 Jun 2016 21:45:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/tRest-does-not-return-a-body-when-getting-a-400-error/m-p/2304028#M75845</guid>
      <dc:creator>_AnonymousUser</dc:creator>
      <dc:date>2016-06-24T21:45:06Z</dc:date>
    </item>
  </channel>
</rss>

