<?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: How to access error body of a custom SDK action? in Workato Pros Discussion Board</title>
    <link>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-access-error-body-of-a-custom-sdk-action/m-p/652#M337</link>
    <description>&lt;P&gt;Thank you &lt;A href="https://systematic.workato.com/workato-migration/users/2373552"&gt;Manuel Roldan-Vega&lt;/A&gt; and &lt;A href="https://systematic.workato.com/workato-migration/users/2371391"&gt;Chandra V&lt;/A&gt; ! Great examples and I believe this is exactly what I needed.&lt;/P&gt;</description>
    <pubDate>Tue, 16 Mar 2021 20:34:56 GMT</pubDate>
    <dc:creator>jason1</dc:creator>
    <dc:date>2021-03-16T20:34:56Z</dc:date>
    <item>
      <title>How to access error body of a custom SDK action?</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-access-error-body-of-a-custom-sdk-action/m-p/649#M334</link>
      <description>&lt;P&gt;When an SDK action fails (e.g. non-200 response code), it's unclear how to access the JSON body of the response to then turn this into a meaningful error message. The "Error Message" pill available through the On Error block does not contain enough information. &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I know for HTTP connectors, you can choose to mark non-200 codes as success and parse the response data in subsequent steps. How can this be achieved easily for custom SDK actions?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 00:50:06 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-access-error-body-of-a-custom-sdk-action/m-p/649#M334</guid>
      <dc:creator>jason1</dc:creator>
      <dc:date>2021-03-16T00:50:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to access error body of a custom SDK action?</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-access-error-body-of-a-custom-sdk-action/m-p/650#M335</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;I use .after_response do |code,body,headers|  block in my http request to handle this. Here's an example of how I get the http code and then use it in the data pills. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 16 Mar 2021 01:17:44 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-access-error-body-of-a-custom-sdk-action/m-p/650#M335</guid>
      <dc:creator>mroldanvega</dc:creator>
      <dc:date>2021-03-16T01:17:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to access error body of a custom SDK action?</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-access-error-body-of-a-custom-sdk-action/m-p/651#M336</link>
      <description>&lt;P&gt;Hi Jason,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Do you want to show the error message received from the target &lt;/P&gt;&lt;P&gt;application instead of suppressing the error (sometimes Workato &lt;/P&gt;&lt;P&gt;show an Internal Server error for the failed job)?&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;we have a method after_error_response which helps to monitor for&lt;/P&gt;&lt;P&gt; all http codes(other than 2XX).&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;For example, the below method monitors for the 404 error code &lt;/P&gt;&lt;P&gt;and displays the error message received from the target application.&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;after_error_response(404) do |code, body, header, message|&lt;/P&gt;&lt;P&gt;  error("#{message}: #{body}")&lt;/P&gt;&lt;P&gt;end&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;the method has 4 args:&lt;/P&gt;&lt;P&gt;code: Error code e.g. 404, 403&lt;/P&gt;&lt;P&gt;body: the response body&lt;/P&gt;&lt;P&gt;headers: header details(response headers)&lt;/P&gt;&lt;P&gt;message: error message&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;Also, you can use regex to monitor multiple error codes with the same method.&lt;/P&gt;&lt;P&gt;for example, after_error_response(/.*/) monitors all error codes(other &lt;/P&gt;&lt;P&gt;than success status codes 2xx).&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;when we receive an API error occurs the code inside the method&lt;/P&gt;&lt;P&gt; i.e. error("#{message}: #{body}") will be executed message is displayed on the &lt;/P&gt;&lt;P&gt; job report.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;We recommend using the error method to show the error message on the job, &lt;/P&gt;&lt;P&gt;this method marks the job as a failed transaction on the recipe and &lt;/P&gt;&lt;P&gt;shows the error under the job report.&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;Otherwise, If you want to use the error message in subsequent steps,&lt;/P&gt;&lt;P&gt; then you should able to do that as well.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;after_error_response(/.*/) do |code, body, header, message|&lt;/P&gt;&lt;P&gt;  {&lt;/P&gt;&lt;P&gt;    code: code,&lt;/P&gt;&lt;P&gt;    body: parse_josn(body),&lt;/P&gt;&lt;P&gt;    headers: headers,&lt;/P&gt;&lt;P&gt;    message: message&lt;/P&gt;&lt;P&gt;  }&lt;/P&gt;&lt;P&gt;end&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;With this approach, the job is marked as success and but you can use error in subsequent steps.&lt;/P&gt;&lt;P&gt;(this works the same as, in HTTP connectors we can choose to mark non-200 codes as success)&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;You should able to use the error message in the downstream application, and then stop the job with the error after logging. with this, you know which job is failed on the job report.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;But we suggest marking the job as failed when there is an error on API call.&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;P&gt;Please find the documentation for more details:&lt;/P&gt;&lt;P&gt;https://docs.workato.com/developing-connectors/sdk/guides/error-handling.html#after-error-response&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 02:27:10 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-access-error-body-of-a-custom-sdk-action/m-p/651#M336</guid>
      <dc:creator>chandra</dc:creator>
      <dc:date>2021-03-16T02:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to access error body of a custom SDK action?</title>
      <link>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-access-error-body-of-a-custom-sdk-action/m-p/652#M337</link>
      <description>&lt;P&gt;Thank you &lt;A href="https://systematic.workato.com/workato-migration/users/2373552"&gt;Manuel Roldan-Vega&lt;/A&gt; and &lt;A href="https://systematic.workato.com/workato-migration/users/2371391"&gt;Chandra V&lt;/A&gt; ! Great examples and I believe this is exactly what I needed.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Mar 2021 20:34:56 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/workato-pros-discussion-board/how-to-access-error-body-of-a-custom-sdk-action/m-p/652#M337</guid>
      <dc:creator>jason1</dc:creator>
      <dc:date>2021-03-16T20:34:56Z</dc:date>
    </item>
  </channel>
</rss>

