How to Continue a Workflow after an Error Response?

This topic was automatically generated from Slack. You can find the original thread here.

Hello! I have a question on how to continue a workflow when you get an error response. video attached. Thank you!

You can do this using a custom code step.

I need the code to make an axios post request to a soap api with a condition to end the workflow early on a success response and continue the workflow on any error response

Based on your requirements, here’s a Pipedream component code snippet that makes an axios POST request to a SOAP API, and uses the response to determine whether to end the workflow early or continue: import { axios } from "@pipedream/platform"; export default defineComponent({ async run({ steps, $ }) { try { const response = await axios($, { method: "POST", url: "https://your-soap-api-endpoint.com", // Replace with your SOAP API endpoint data: "<Your SOAP Request Body>", // Replace with your SOAP request body headers: { "Content-Type": "text/xml; charset=utf-8", // Set the appropriate Content-Type for SOAP // Add any other necessary headers here }, }); // Check for a success condition in the response if (response.data.includes("<Your Success Condition>")) { // Replace with your success condition // End the workflow early on success $.flow.exit("Ending workflow early due to success response"); } else { // Continue the workflow on any other response return response.data; } } catch (error) { // Continue the workflow on error $.flow.rerun("An error occurred, continuing the workflow", { delay_seconds: 1 }); } }, }); Please replace "https://your-soap-api-endpoint.com", "<Your SOAP Request Body>", and "<Your Success Condition>" with the actual endpoint, request body, and success condition for your SOAP API. This code attempts to make a POST request to the SOAP API and checks the response for a success condition. If the success condition is met, it ends the workflow early. If the success condition is not met or an error occurs, it continues the workflow. In the case of an error, it reruns the workflow after a delay of 1 second. Adjust the error handling logic as needed for your use case.