<?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 How to handle errors with tHttpRequest in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/How-to-handle-errors-with-tHttpRequest/m-p/2327204#M96604</link>
    <description>&lt;P&gt;I am posting to a URL that returns an error 400 Bad Request however I cannot seem to get access to the actual http response body.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;If I&amp;nbsp;send tHttpRequest to a tLogRow, it just logs 400 Bad Request.&lt;/P&gt; 
&lt;P&gt;=== begin console output&lt;/P&gt; 
&lt;P class="p1"&gt;&lt;I&gt;Starting job HandlingErrors at 16:46 14/05/2018.&lt;/I&gt;&lt;/P&gt; 
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P class="p3"&gt;[statistics] connecting to socket on port 3742&lt;/P&gt; 
&lt;P class="p3"&gt;[statistics] connected&lt;/P&gt; 
&lt;P class="p4"&gt;Exception in component tHttpRequest_1&lt;/P&gt; 
&lt;P class="p4"&gt;java.lang.RuntimeException: Request failed:400 Bad Request&lt;/P&gt; 
&lt;P class="p4"&gt;at thrust2bq.handlingerrors_0_1.HandlingErrors.tHttpRequest_1Process(HandlingErrors.java:673)&lt;/P&gt; 
&lt;P class="p4"&gt;at thrust2bq.handlingerrors_0_1.HandlingErrors.runJobInTOS(HandlingErrors.java:1011)&lt;/P&gt; 
&lt;P class="p4"&gt;at thrust2bq.handlingerrors_0_1.HandlingErrors.main(HandlingErrors.java:868)&lt;/P&gt; 
&lt;P class="p3"&gt;[statistics] disconnected&lt;/P&gt; 
&lt;P class="p1"&gt;&lt;I&gt;Job HandlingErrors ended at 16:46 14/05/2018. [exit code=1]&lt;/I&gt;&lt;/P&gt; 
&lt;P&gt;==== end console output&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;STRONG&gt;Using Postman&lt;/STRONG&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;If I use postman, it returns the body of the response.&lt;/P&gt; 
&lt;P&gt;{&lt;BR /&gt;"status": "SM_ERROR",&lt;BR /&gt;"errors": [&lt;BR /&gt;{&lt;BR /&gt;"error": "BAD_REQUEST",&lt;BR /&gt;"message": "Friendly Error Message Here"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"requestkey": ""&lt;BR /&gt;}&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I have even tried putting a tExtractJSONFields after the tHttpRequest but the ResponseContent is never filled in because of the "error" condition.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;So the question is: How&amp;nbsp;can I get the Response Body content from the tHttpRequest regardless if there is an error condition (non-200 Http Status)?&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Ultimately, what I am trying to do is:&lt;/P&gt; 
&lt;OL&gt; 
 &lt;LI&gt;I have a file thousands of rows of post data that I need to send one at a time to a URL (API)&lt;/LI&gt; 
 &lt;LI&gt;Parse the JSON response and IF error, write the response body to a log file. If success, extract a key value from the response body and write to a success file.&lt;/LI&gt; 
&lt;/OL&gt; 
&lt;P&gt;If there is NO error, then everything works fine. But as soon as the error happens,&amp;nbsp;processing stops. FWIW I did uncheck the "die on error" box but is seems that as soon as an error occurs, the tExtractJSONFields stops working and I no longer get any successes written to my success log file.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I am using Talend Open Studio for BigData 6.3.0 on macOS 10.12.6&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Anywho, thank you for any assistance you can provide.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 15 May 2018 00:58:03 GMT</pubDate>
    <dc:creator>JamesR1</dc:creator>
    <dc:date>2018-05-15T00:58:03Z</dc:date>
    <item>
      <title>How to handle errors with tHttpRequest</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-handle-errors-with-tHttpRequest/m-p/2327204#M96604</link>
      <description>&lt;P&gt;I am posting to a URL that returns an error 400 Bad Request however I cannot seem to get access to the actual http response body.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;If I&amp;nbsp;send tHttpRequest to a tLogRow, it just logs 400 Bad Request.&lt;/P&gt; 
&lt;P&gt;=== begin console output&lt;/P&gt; 
&lt;P class="p1"&gt;&lt;I&gt;Starting job HandlingErrors at 16:46 14/05/2018.&lt;/I&gt;&lt;/P&gt; 
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P class="p3"&gt;[statistics] connecting to socket on port 3742&lt;/P&gt; 
&lt;P class="p3"&gt;[statistics] connected&lt;/P&gt; 
&lt;P class="p4"&gt;Exception in component tHttpRequest_1&lt;/P&gt; 
&lt;P class="p4"&gt;java.lang.RuntimeException: Request failed:400 Bad Request&lt;/P&gt; 
&lt;P class="p4"&gt;at thrust2bq.handlingerrors_0_1.HandlingErrors.tHttpRequest_1Process(HandlingErrors.java:673)&lt;/P&gt; 
&lt;P class="p4"&gt;at thrust2bq.handlingerrors_0_1.HandlingErrors.runJobInTOS(HandlingErrors.java:1011)&lt;/P&gt; 
&lt;P class="p4"&gt;at thrust2bq.handlingerrors_0_1.HandlingErrors.main(HandlingErrors.java:868)&lt;/P&gt; 
&lt;P class="p3"&gt;[statistics] disconnected&lt;/P&gt; 
&lt;P class="p1"&gt;&lt;I&gt;Job HandlingErrors ended at 16:46 14/05/2018. [exit code=1]&lt;/I&gt;&lt;/P&gt; 
&lt;P&gt;==== end console output&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;STRONG&gt;Using Postman&lt;/STRONG&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;If I use postman, it returns the body of the response.&lt;/P&gt; 
&lt;P&gt;{&lt;BR /&gt;"status": "SM_ERROR",&lt;BR /&gt;"errors": [&lt;BR /&gt;{&lt;BR /&gt;"error": "BAD_REQUEST",&lt;BR /&gt;"message": "Friendly Error Message Here"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"requestkey": ""&lt;BR /&gt;}&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I have even tried putting a tExtractJSONFields after the tHttpRequest but the ResponseContent is never filled in because of the "error" condition.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;So the question is: How&amp;nbsp;can I get the Response Body content from the tHttpRequest regardless if there is an error condition (non-200 Http Status)?&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Ultimately, what I am trying to do is:&lt;/P&gt; 
&lt;OL&gt; 
 &lt;LI&gt;I have a file thousands of rows of post data that I need to send one at a time to a URL (API)&lt;/LI&gt; 
 &lt;LI&gt;Parse the JSON response and IF error, write the response body to a log file. If success, extract a key value from the response body and write to a success file.&lt;/LI&gt; 
&lt;/OL&gt; 
&lt;P&gt;If there is NO error, then everything works fine. But as soon as the error happens,&amp;nbsp;processing stops. FWIW I did uncheck the "die on error" box but is seems that as soon as an error occurs, the tExtractJSONFields stops working and I no longer get any successes written to my success log file.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I am using Talend Open Studio for BigData 6.3.0 on macOS 10.12.6&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Anywho, thank you for any assistance you can provide.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 May 2018 00:58:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-handle-errors-with-tHttpRequest/m-p/2327204#M96604</guid>
      <dc:creator>JamesR1</dc:creator>
      <dc:date>2018-05-15T00:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle errors with tHttpRequest</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-handle-errors-with-tHttpRequest/m-p/2327205#M96605</link>
      <description>&lt;P&gt;I'm facing the exact same issue. I get an error 400, but I'd like to see the actual response so I understand why.&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 18:36:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-handle-errors-with-tHttpRequest/m-p/2327205#M96605</guid>
      <dc:creator>markdjenkins</dc:creator>
      <dc:date>2018-05-16T18:36:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle errors with tHttpRequest</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-handle-errors-with-tHttpRequest/m-p/2327206#M96606</link>
      <description>&lt;P&gt;Could you make a screendump of your job flow, the url itself and the data.&lt;/P&gt; 
&lt;P&gt;A common mistake is due to:&lt;BR /&gt;1 - incorrect headers. your endpoint provider should give you the specs to make correct call.&lt;/P&gt; 
&lt;P&gt;2 - GET just to get a response based on endpoint with formvars to be able to query data. often mistaken with POST&lt;/P&gt; 
&lt;P&gt;3 - PUT (filedata), when you want to upload a lot of shizzle.&lt;/P&gt; 
&lt;P&gt;4 - POST (like web-form vars ?startDate=2015-01-02 ) , make sure your headers are set ok!&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;5 - Incorrect url and data ... spaces not escaped special chars etc etc etc...&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;On server side its trying to parse your request (your composed url).&amp;nbsp;And with a 400 bad request make sure step 1 is correct.&lt;/P&gt; 
&lt;P&gt;Use a tRestClient which is really flexible in&amp;nbsp;handling response, the good and the bad.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Good luck!&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 21:01:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-handle-errors-with-tHttpRequest/m-p/2327206#M96606</guid>
      <dc:creator>Jesperrekuh</dc:creator>
      <dc:date>2018-05-16T21:01:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle errors with tHttpRequest</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-handle-errors-with-tHttpRequest/m-p/2327207#M96607</link>
      <description>&lt;P&gt;Thank you for responding.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Screenshots added. I obfuscated the URL.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;FWIW, calls to the API work fine until there is a non-200 http status code.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The postdata looks like:&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;userId=38340824&amp;amp;streamId=6481006509&amp;amp;rateId=8135506&amp;amp;chargeSource=HybridClientFix&amp;amp;amount=300&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;No spaces in the POST parameters&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Complete URL is:&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;A href="https://api.url.com/v1/charge/charge" target="_blank" rel="nofollow noopener noreferrer"&gt;https://api.url.com/v1/charge/charge&lt;/A&gt;?&lt;/P&gt; 
&lt;P&gt;userId=38340824&amp;amp;streamId=6481006509&amp;amp;rateId=8135506&amp;amp;chargeSource=HybridClientFix&amp;amp;amount=300&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Worflow" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009Lxgk.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/156067iC266EB937537AD77/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lxgk.png" alt="0683p000009Lxgk.png" /&gt;&lt;/span&gt;&lt;SPAN class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Worflow&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HttpRequest headers" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009Lxgu.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/154138i427253C0FA6FC487/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009Lxgu.png" alt="0683p000009Lxgu.png" /&gt;&lt;/span&gt;&lt;SPAN class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;HttpRequest headers&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 21:31:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-handle-errors-with-tHttpRequest/m-p/2327207#M96607</guid>
      <dc:creator>JamesR1</dc:creator>
      <dc:date>2018-05-16T21:31:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle errors with tHttpRequest</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-handle-errors-with-tHttpRequest/m-p/2327208#M96608</link>
      <description>&lt;P&gt;Could you please provide the wrong url which result in the 400 bad request?&lt;BR /&gt;The url you post looks allright to me.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt; 
&lt;P&gt;Although your job ... I suggest&amp;nbsp; change :&lt;/P&gt; 
&lt;P&gt;&lt;EM&gt;[write post data] ------&amp;nbsp;&lt;/EM&gt;ROW2 -----&amp;gt; &lt;EM&gt;[Call billing api]&lt;/EM&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;into&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&lt;EM&gt;[write post data] ------&amp;nbsp;On Subjob Ok&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;-----&amp;gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;[Call billing api]&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Maybe the post data file isn't ready and sends&amp;nbsp;no parameters&lt;BR /&gt;&lt;BR /&gt;Last suggestion because of money .... make sure the amount is in the correct notations decimals. thousands etc... as clean as possible&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 22:38:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-handle-errors-with-tHttpRequest/m-p/2327208#M96608</guid>
      <dc:creator>Jesperrekuh</dc:creator>
      <dc:date>2018-05-16T22:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle errors with tHttpRequest</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-handle-errors-with-tHttpRequest/m-p/2327209#M96609</link>
      <description>&lt;P&gt;the post data I identified in the previous comment contains the data that produces the 400. With the&amp;nbsp;JSON in my original message&amp;nbsp;in the HTTP response.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;FWIW, I&amp;nbsp;even tried manually creating the postdata.txt file and feeding that the tHttpRequest and get the same error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Amount field is purposefully sent as cents (no decimal).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will try your suggestion on the workflow --&amp;gt; onSubJobOk but I am thinking the issue lies in the tHttpRequest component treating any non-200 http status code as an error and NOT making the http response body available.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you successfully been able to retrieve the HTTP response body when the http status != 200?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 22:46:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-handle-errors-with-tHttpRequest/m-p/2327209#M96609</guid>
      <dc:creator>JamesR1</dc:creator>
      <dc:date>2018-05-16T22:46:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle errors with tHttpRequest</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-handle-errors-with-tHttpRequest/m-p/2327210#M96610</link>
      <description>&lt;P&gt;I agree. I played with it for a few hours and I could never make the response body available when the status code was&amp;nbsp;non-200.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I eventually gave up and migrated to using the tRest component to do my POST request. It provides a &amp;lt;null&amp;gt; status code when a 200 is given and a valid status code when anything other than 200 is given. This in turn allowed me to use an 'if' statement against that value to determine success or failure (yet still having the response body to log or handle as necessary).&lt;/P&gt;</description>
      <pubDate>Wed, 16 May 2018 23:18:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-handle-errors-with-tHttpRequest/m-p/2327210#M96610</guid>
      <dc:creator>markdjenkins</dc:creator>
      <dc:date>2018-05-16T23:18:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle errors with tHttpRequest</title>
      <link>https://community.qlik.com/t5/Talend-Studio/How-to-handle-errors-with-tHttpRequest/m-p/2327211#M96611</link>
      <description>&lt;P&gt;tRestClient is a better solution and provide this ... but however... I did more or less the same as you, look at attachment&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;A href="https://community.qlik.com/legacyfs/online/tlnd_dw_files/0683p000009Lstp"&gt;REST.jpg&lt;/A&gt;</description>
      <pubDate>Wed, 16 May 2018 23:38:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/How-to-handle-errors-with-tHttpRequest/m-p/2327211#M96611</guid>
      <dc:creator>Jesperrekuh</dc:creator>
      <dc:date>2018-05-16T23:38:47Z</dc:date>
    </item>
  </channel>
</rss>

