cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Method to check for invalid URLs

bedelman0731
Deputy Chef II
Deputy Chef II

Is there a method by which a URL can be checked within a recipe to see if the URL is valid?

I have a recipe that, among other things, is constructing a URL that should be a reference to an image based on one of the ID of a data element. The issue arises in that the image has not always been uploaded and the URL that should point to the image returns a 404 (Page Not Found).

The output of the recipe is a CSV file where each row contains what "should" be the URL to the image, but (in some cases) the image has not been uploaded and the URL that it would have then throws a 404.

I did find a App Script for Google Sheets that will check the URLs - but this requires importing the CSV into Google Sheets, adding in the App Script, adding a column that then uses the App Script function to return the status of the URL. All of these are additional steps that I would prefer to avoid and merely do the URL checking within the recipe itself.

Is there a way to implement such a URL checker into a recipe in Workato?

7 REPLIES 7

I get that completely - but I did not really see a way in which this could be done using Workato actions

I agree on using Workato actions whenever possible, but I didn't really find a good way to check a URL by doing so. What did you have in mind as a way to do this using basic Workato actions?

gary1
Executive Chef III
Executive Chef III

It's a two step process.

  1. Use the HTTP action to call the URL
  2. Log the status code from the response

Here's a closer look.

Two actions:

url1.jpg

Set up the HTTP action like the below. A GET request to a URL (you'll use a data pill since you'll be in a loop). Set the response type to "Text" so it doesn't try to parse the response (if it were set to JSON, it would crash).

url2.jpg

Very important, set the below to "Yes". Usually when you receive a 404 the recipe will throw an error, but this will prevent the error and your recipe will continue.

url3.jpg

In this step, simply log the status code data pill from the output of the HTTP action. This could be in a list variable or really anywhere/anything else.

url4.jpg

In the HTTP action output, a 200/success will look like this:

url5.jpg

And a 404 will look like this:

url6.jpg