Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Knowledge Base

Definitive answers from Designer Desktop experts.

Guide to Creating Your Own Connector - Handling Errors

DeniseF
Alteryx
Alteryx
Created

This article is part of the "Guide to Creating Your Own Connector" series

Handling Errors

Now you are ready to take your workflow one step further and add some error checking. If something is wrong with your request or something goes wrong on the server, an API will usually return an error message. It is useful to capture this information and clearly display it to the user of the connector. The Message tool will come in handy here. It will help you to troubleshoot the error and actually stop the workflow from processing if you would like. The Download toolreturns two fields, “DownloadHeaders” and “DownloadData”. The HTTP status codes are returned via the “DownloadHeaders” field. The actual data provided by the API will be contained in the “DownloadData” field. Below is an example of what a workflow would look like.

ErrorWorkflowExample.png

The Message tool should be placed after the Download tool, but before the parsing tool in your workflow. Placing the message tool here ensures the workflow will stop running when it encounters an error. In the Configuration window, you will select “Before Rows Where Expression is True”. The REGEX expression below says to throw an error when the HTTP status code (returned in the “DownloadHeaders” field) starts with something other than a 1 or 2. APIs return header information in different ways so you will probably need to tweak the header parsing algorithm to suit your use case. The Message Type will be “Error - And Stop Passing Records Through This Tool”. The Message Expression should include the Headers and Data info from the API. This will help to troubleshoot the error.


message1.JPG



Some classes of errors you may encounter are listed below. A detailed list of HTTP status codes is located herefor reference.

  • 1xx Informational - Indicates the request was received.
  • 2xx Success - Indicates the action requested by the client was received, understood, accepted, and processed successfully.
  • 3xx Redirection - Indicates the client must take additional action to complete the request.
  • 4xx Client Error - intended for situations in which the client seems to have erred.
  • 5xx Server Error - Indicates the server failed to fulfill an apparently valid request.

Throttling

If the API you are connecting to has request limitations, like 5/10 per second, it can be useful to use a Throttle tool to precede the Download tool, so that only a certain number of records are passed through at a certain time.

Comments
EvanSchmidt
6 - Meteoroid

Very helpful article. Thanks!

FredericP
Alteryx Alumni (Retired)

What is the character in the Regex code between HTTP and 1.1?

It would be helpful if you could provide the regex code in your text, ready to copy and paste...

We are not all Regex gods, alas...

DeniseF
Alteryx
Alteryx

Hi @FredericP,

 

LOL! I am far from a Regex god. regexr.com is my friend. It is a backslash, then a forward slash. Here is the code to copy/paste:

 

REGEX_Match([DownloadHeaders], '.*HTTP\/1.1 [^12].*')

 

Let me know if this is what you need!

 

Thank you,

@DeniseF

MarqueeCrew
20 - Arcturus
20 - Arcturus

@FredericP & @DeniseF,

 

In the RegEx expression a backslash followed by the forward slash is how you would look for a forward slash.  If you were looking for an asterisk, it would look like:  \*

 

Cheers,

Mark

FredericP
Alteryx Alumni (Retired)

Exactly what I needed, thank you Denise!

Never came across that \/ before...

Thanks for the context Mark, makes much more sense to me now!

russellclaude
6 - Meteoroid

Very helpful, thank you! I have a problem with the Download Connector, though.

 

The workflow on the right works awesome. The Download connector tool receives a URL from the Text Input tile, but obviously those are all manually pasted in. This is not ideal. The flow on the LEFT would hopefully make the process much more automated, supplying the URLs that need to be processed. However, Facebook doesn’t seem to like what the Download Connector asks for when these two flows are connected. The work-around is that I run them separately, and I copy/paste the results (URL and Store #) into the Text Input tile manually. It works like a charm, just a huge pain in the rear. I have seen a few comments in the forums where folks have had same issue. Ideas?

 

Capture.PNG

usmost
5 - Atom

 

 

 

 

Great article.  Helpful information relative possible request limitation and how to resolve Throttling issues.  The Guide to Creating Your Own Connector series has served to be instructive and practical.