How to ignore 422 Error on HTTP request and PUT remaining data

I created a HTTP request to push data to my CRM. It works until I make a request with a duplicate email or duplicate phone number. Is there any way to ignore the duplicate email (or phone) and still post the rest of the data? Or any other suggestions work arounds?

Here is the error from the output.
“data”: “<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n Phone number ‘800-555-1212’ has already been taken\n\n”,

Here is the entire output

[
    {
        "statusCode": 422,
        "headers": [
            {
                "name": "date",
                "value": "Wed, 17 Jul 2024 04:46:51 GMT"
            },
            {
                "name": "content-type",
                "value": "application/xml; charset=utf-8"
            },
            {
                "name": "content-length",
                "value": "126"
            },
            {
                "name": "connection",
                "value": "keep-alive"
            },
            {
                "name": "cache-control",
                "value": "no-cache"
            },
            {
                "name": "set-cookie",
                "value": "_sunrise_session=BAh7BzoPc2Vzc2lvbl9pZEkiJTg4NDU5OWQ1YjEwOWRkNzNiNmE5OWQ0ODUxYTUwMmNhBjoGRUY6EF9jc3JmX3Rva2VuSSIxcDJZYkFBVzdJa3RYYUlUai9STE5kUVBsdDE5a0oxRDFmRlh2VHFaOXdXTT0GOwZG--8ab6ed7b963c74c9e43dfd56e54ea576b77df7b3; path=/; HttpOnly; secure"
            },
            {
                "name": "status",
                "value": "422 Unprocessable Entity"
            },
            {
                "name": "strict-transport-security",
                "value": "max-age=31536000"
            },
            {
                "name": "x-frame-options",
                "value": "SAMEORIGIN"
            },
            {
                "name": "x-hrhq-version",
                "value": "deploy:rails; ref:ad5a95297680e962026171d778540e7bcbae18e8"
            },
            {
                "name": "x-request-id",
                "value": "f349013c06be5e5f14fa6b3a35191b9e"
            },
            {
                "name": "x-throttle-count",
                "value": "1"
            },
            {
                "name": "x-throttle-horizon",
                "value": "2024-07-17T04:46:55Z"
            },
            {
                "name": "x-throttle-max",
                "value": "150"
            },
            {
                "name": "cf-cache-status",
                "value": "DYNAMIC"
            },
            {
                "name": "server",
                "value": "cloudflare"
            },
            {
                "name": "cf-ray",
                "value": "8a47973508d4061c-IAD"
            },
            {
                "name": "alt-svc",
                "value": "h3=\":443\"; ma=86400"
            }
        ],
        "cookieHeaders": [
            "_sunrise_session=BAh7BzoPc2Vzc2lvbl9pZEkiJTg4NDU5OWQ1YjEwOWRkNzNiNmE5OWQ0ODUxYTUwMmNhBjoGRUY6EF9jc3JmX3Rva2VuSSIxcDJZYkFBVzdJa3RYYUlUai9STE5kUVBsdDE5a0oxRDFmRlh2VHFaOXdXTT0GOwZG--8ab6ed7b963c74c9e43dfd56e54ea576b77df7b3; path=/; HttpOnly; secure"
        ],
        "data": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<errors>\n  <error>Phone number '800-555-1212' has already been taken</error>\n</errors>\n",
        "fileSize": 126
    }
]

If the module throws an error, simply clone the same module into an error handling route, and remove the phone number variable. This retries without the phone number.

Then, use a Resume directive and map the output of the cloned module into it.

Handle errors so scenarios don’t stop.

You might want to add some error handling to your modules to handle exceptions, so the failing module(s) can automatically be retried or ignored. By handling any errors by adding a “Error handler” to the module, the scenario won’t throw an error and get turned off.

Error directives can only be added to an error handler route.

1. Right click and select “Add error handler”

2. Error handlers will appear

For more information on error handling, see:

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!

Thank you. Any suggestions on how I identify the data that throws the error since it will not just be isolated to phone numbers? It could be either the same email or the same phone number. In the example I provided, it was a phone number, but it could hav been an email.

Here is what happens with the email error:
Data <?xml version="1.0" encoding="UTF-8"?>

Email ‘myemail@email.com’ has already been taken

I’ve tried what you suggested (copied the same data but removed the phone number XML that triggers the error) but the data doesn’t move to the next module. It stops at the first error.

I found one work around without an error handler. If I create a filter to look for Status Code 422. I can copy the same module without the error data. It works, but is there a way to do this with the error handling as originally suggestions?

I think the issue with my scenario is the error is displayed as XML output instead of a traditional error message.

image

To get the HTTP module to throw an error when you get 422,

You need to turn on the advanced settings and scroll all the way up to the first field, and toggle it to YES.

Screenshot_20240719_162446

samliewrequest private consultation

Join the Make Fans Discord server to chat with other makers!