<?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>question how to get error response like 400 and 500 using InvokeHTTP processor in Apache NiFi? in Support Questions</title>
    <link>https://community.cloudera.com/t5/Support-Questions/how-to-get-error-response-like-400-and-500-using-InvokeHTTP/m-p/398962#M250348</link>
    <description>&lt;P&gt;Hello sir,&lt;/P&gt;&lt;P&gt;I am using the InvokeHTTP processor in Apache NiFi to call an API. I am writing the response using the PutFile processor. When the API returns a 200 status code, it works fine and writes the response. However, when the API returns a 400 or 500 status code, it writes the original input file instead. I want to capture and write the actual response body for 400 or 500 status codes instead of the input file. here is process:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="enam_0-1734415482731.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43103i1D3C61961DD0D93F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="enam_0-1734415482731.png" alt="enam_0-1734415482731.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;here is InvokeHTTP processor:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="enam_1-1734415773091.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43104i5BE1FA226A5D8D5A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="enam_1-1734415773091.png" alt="enam_1-1734415773091.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is putfile processor:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="enam_2-1734415833246.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43105iC73A96BD0BE4FB9B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="enam_2-1734415833246.png" alt="enam_2-1734415833246.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;if status 200 it write the response . I want write all response from api instead of input file if it has any status from api.&lt;/P&gt;&lt;P&gt;Please help me&lt;/P&gt;</description>
    <pubDate>Tue, 17 Dec 2024 06:14:59 GMT</pubDate>
    <dc:creator>enam</dc:creator>
    <dc:date>2024-12-17T06:14:59Z</dc:date>
    <item>
      <title>how to get error response like 400 and 500 using InvokeHTTP processor in Apache NiFi?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-get-error-response-like-400-and-500-using-InvokeHTTP/m-p/398962#M250348</link>
      <description>&lt;P&gt;Hello sir,&lt;/P&gt;&lt;P&gt;I am using the InvokeHTTP processor in Apache NiFi to call an API. I am writing the response using the PutFile processor. When the API returns a 200 status code, it works fine and writes the response. However, when the API returns a 400 or 500 status code, it writes the original input file instead. I want to capture and write the actual response body for 400 or 500 status codes instead of the input file. here is process:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="enam_0-1734415482731.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43103i1D3C61961DD0D93F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="enam_0-1734415482731.png" alt="enam_0-1734415482731.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;here is InvokeHTTP processor:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="enam_1-1734415773091.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43104i5BE1FA226A5D8D5A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="enam_1-1734415773091.png" alt="enam_1-1734415773091.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is putfile processor:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="enam_2-1734415833246.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43105iC73A96BD0BE4FB9B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="enam_2-1734415833246.png" alt="enam_2-1734415833246.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;if status 200 it write the response . I want write all response from api instead of input file if it has any status from api.&lt;/P&gt;&lt;P&gt;Please help me&lt;/P&gt;</description>
      <pubDate>Tue, 17 Dec 2024 06:14:59 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-get-error-response-like-400-and-500-using-InvokeHTTP/m-p/398962#M250348</guid>
      <dc:creator>enam</dc:creator>
      <dc:date>2024-12-17T06:14:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to get error response like 400 and 500 using InvokeHTTP processor in Apache NiFi?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-get-error-response-like-400-and-500-using-InvokeHTTP/m-p/399184#M250435</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/108435"&gt;@enam&lt;/a&gt;&amp;nbsp;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;I see you have used the correct&amp;nbsp;&amp;nbsp;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;InvokeHTTP&lt;/STRONG&gt;&lt;/FONT&gt; processor which is used to send API requests and handle responses, including error codes 400, 500 etc.&lt;/FONT&gt;&lt;/P&gt;&lt;H4&gt;&lt;FONT size="2"&gt;Configuration for&lt;STRONG&gt; InvokeHTTP:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/H4&gt;&lt;H4&gt;&lt;FONT size="2"&gt;Set Required Properties:&lt;/FONT&gt;&lt;/H4&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;HTTP Method&lt;/STRONG&gt;:&amp;nbsp;&amp;nbsp;&lt;FONT color="#0000FF"&gt;POST&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Remote URL&lt;/STRONG&gt;: &lt;FONT color="#0000FF"&gt;&lt;A href="http://192.168.200.162:2031/nostroliquidity" target="_blank"&gt;http://192.168.200.162:2031/nostroliquidity&lt;/A&gt;........&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Return Code&lt;/STRONG&gt;: Ensure &lt;FONT color="#0000FF"&gt;Success Codes&lt;/FONT&gt; includes only &lt;FONT color="#0000FF"&gt;2xx&lt;/FONT&gt; responses by default.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;FONT size="2"&gt;To enable Error Responses add the following settings:&lt;/FONT&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;"Always Output Response"&lt;/STRONG&gt;: Set to &lt;FONT color="#0000FF"&gt;true&lt;/FONT&gt;.&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Output Response Attributes&lt;/STRONG&gt;: Include attributes such as &lt;FONT color="#0000FF"&gt;status.code&lt;/FONT&gt; and &lt;FONT color="#0000FF"&gt;status.message&lt;/FONT&gt; to capture response metadata.&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;This ensures that the processor outputs responses regardless of status code.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Now route Responses Based on Status Code&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;H4&gt;&lt;FONT size="2"&gt;Use the &lt;FONT color="#0000FF"&gt;RouteOnAttribute&lt;/FONT&gt; processor to differentiate between success and error responses add two conditions:&lt;/FONT&gt;&lt;/H4&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Success Route&lt;/STRONG&gt;: Check for &lt;FONT color="#0000FF"&gt;status.code &amp;gt;= 200 AND status.code &amp;lt; 300&lt;/FONT&gt;.&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Error Route&lt;/STRONG&gt;: Check for &lt;FONT color="#0000FF"&gt;status.code &amp;gt;= 400&lt;/FONT&gt;.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;FONT size="2"&gt;Connect the &lt;FONT color="#0000FF"&gt;InvokeHTTP&lt;/FONT&gt; processor's &lt;FONT color="#0000FF"&gt;Response&lt;/FONT&gt; relationship to the &lt;FONT color="#0000FF"&gt;RouteOnAttribute&lt;/FONT&gt; processor.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;To write Responses to Appropriate Locations&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Use a &lt;FONT color="#0000FF"&gt;PutFile&lt;/FONT&gt; or &lt;FONT color="#0000FF"&gt;PutHDFS&lt;/FONT&gt; processor for both success and error routes:&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Success Route:&lt;/FONT&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Write successful responses to a specific directory.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Error Route:&lt;/FONT&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Write error responses &lt;FONT color="#0000FF"&gt;400&lt;/FONT&gt;, &lt;FONT color="#0000FF"&gt;500&amp;nbsp;&lt;/FONT&gt;to a separate directory.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;FONT size="2"&gt;Include response details for debugging.&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-SPOILER&gt;&lt;FONT size="2"&gt;GenerateFlowFile --&amp;gt; InvokeHTTP --&amp;gt; RouteOnAttribute --&amp;gt; [Success] PutFile&amp;nbsp;--&amp;gt; [Error] PutFile&lt;/FONT&gt;&lt;/LI-SPOILER&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Important Configuration Notes&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Configure Failure Handling in &lt;/STRONG&gt;&lt;FONT color="#0000FF"&gt;InvokeHTTP&lt;/FONT&gt;&lt;STRONG&gt;:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Connect the &lt;FONT color="#0000FF"&gt;InvokeHTTP&lt;/FONT&gt; processor’s &lt;FONT color="#0000FF"&gt;Original&lt;/FONT&gt; relationship to a &lt;FONT color="#0000FF"&gt;LogMessage&lt;/FONT&gt; processor or another flow to avoid losing the original flowfile.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Customize Filenames or Attributes:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Use &lt;FONT color="#0000FF"&gt;UpdateAttribute&lt;/FONT&gt; to set filenames or directories dynamically based on attributes like &lt;FONT color="#0000FF"&gt;status.code &lt;/FONT&gt;or &lt;FONT color="#0000FF"&gt;status.message.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Capture Full API Responses:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;Ensure that &lt;FONT color="#0000FF"&gt;Response Body&lt;/FONT&gt; from the API is written as the content of the output file.&lt;/FONT&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;FONT size="2"&gt;Can you run the above flow and revert&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Happy hadooping&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Dec 2024 07:07:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-get-error-response-like-400-and-500-using-InvokeHTTP/m-p/399184#M250435</guid>
      <dc:creator>Shelton</dc:creator>
      <dc:date>2024-12-20T07:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: how to get error response like 400 and 500 using InvokeHTTP processor in Apache NiFi?</title>
      <link>https://community.cloudera.com/t5/Support-Questions/how-to-get-error-response-like-400-and-500-using-InvokeHTTP/m-p/399356#M250478</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/20288"&gt;@Shelton&lt;/a&gt;&amp;nbsp;sorry for late reply:&lt;/P&gt;&lt;P&gt;Here is my json response 400:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="enam_0-1735191822786.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43213iA07412DF927D39CB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="enam_0-1735191822786.png" alt="enam_0-1735191822786.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is invoke HTTP:&amp;nbsp; I have used below properties in invokhttp like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;&amp;nbsp;Always Output Response &lt;/STRONG&gt;: Set to &lt;FONT color="#0000FF"&gt;true&lt;/FONT&gt;.&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Output Response Attributes&lt;/STRONG&gt;:&lt;/FONT&gt; 400 and 500&lt;/LI&gt;&lt;/UL&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="enam_1-1735192034349.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43215i4D0B7433CC02DC4C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="enam_1-1735192034349.png" alt="enam_1-1735192034349.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is &lt;SPAN class="dialog-header-subtitle"&gt;RouteOnAttribute:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="enam_2-1735192194345.png" style="width: 400px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/43216i9909370B683D35A0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="enam_2-1735192194345.png" alt="enam_2-1735192194345.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Is it like that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Dec 2024 05:50:41 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Support-Questions/how-to-get-error-response-like-400-and-500-using-InvokeHTTP/m-p/399356#M250478</guid>
      <dc:creator>enam</dc:creator>
      <dc:date>2024-12-26T05:50:41Z</dc:date>
    </item>
  </channel>
</rss>

