This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
06-03-2016 11:17 AM - edited 08-03-2021 01:09 PM
This article is part of the "Guide to Creating Your Own Connector" series
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.
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.
Some classes of errors you may encounter are listed below. A detailed list of HTTP status codes is located herefor reference.
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.
Very helpful article. Thanks!
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...
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,
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
Exactly what I needed, thank you Denise!
Never came across that \/ before...
Thanks for the context Mark, makes much more sense to me now!
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?
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.