[ardoHTTP] [ardoHTTP] - Invalid URI: The format of the URI could not be determined.

Forge Component
(20)
Published on 2019-01-20 by Ricardo Silva
20 votes
Published on 2019-01-20 by Ricardo Silva

Hello Ricardo

I am trying to use HTTPGet action from this component in order to validate a URL.


My use case is the following:

1) I have a form with several fields, one of those fields is a URL

2)  When I press Save on that form, I only want the changes to be saved if the URL is valid

3) To do so, I encapsulated the HTTPGet action in an action of my own that returns a Success (boolean, True if HTTPGet.Status = "OK", false otherwise) and a Message, bound to the HTTPGet.Response field

4) I'm passing the value the User types in the form's URL input format to this action

5) If the HTTPGet action returns valid, the action's flow continues to save the changes to the database, otherwise, it should throw a message telling the user the URL is not valid and thus not commiting any changes to the Database


The problem is I get an Exception when the debugger reaches the HTTGet action with the message 'Invalid URI: The format of the URI could not be determined.' even though I'm testing with a pretty standard URL (www.google.com). Am I doing something wrong?


I'm using version 1.2.0 since I'm using Service Studio version 10.0.904.0


Best regards

Might be a silly question, but does your URL have the https:// / https:// at the beginning?


Hello Ricardo, thank you for replying so quickly


I was not typing the https:// bit, and now that I am, it works. The problem is, I wanted to use this component in order to validate if the typed URL was a valid one. This means that if the user types https://www.google.com, the action should return Success = true, but if the user types something like https://addrfweqrweqr, it should return Success = false, which isn't the case, but maybe this is not what this action is supposed to do


Best regards,

Ângelo Sousa 

Hello Ângelo Sousa, 

have you found any solution to this problem? 

I am trying to do exactly the same URL validation, and I get the same Exception when the debugger reaches the HTTGet action.

I'm using version 1.2.2 since I'm using Service Studio version 11.5.39

Best Regards,

Tomás Dionísio.

Tomás Dionísio wrote:

Hello Ângelo Sousa, 

have you found any solution to this problem? 

I am trying to do exactly the same URL validation, and I get the same Exception when the debugger reaches the HTTGet action.

I'm using version 1.2.2 since I'm using Service Studio version 11.5.39

Best Regards,

Tomás Dionísio.


Hello again, 

Once this exception from HTTGet action keeps occurring, we can also validate URL via Regex Search. Using a pattern to check if URL includes HTTPS protocol, and has domain. 

Pattern used: 

SyntaxEditor Code Snippet

"^(http|https|ftp):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$"

Note: this method only does URL validation, it doesn't check if site can be reached. 

Best Regards,

Tomás Dionísio.

You could verify if a connection can be established by using the HTTP HEAD operation. This is basically the same as a Get but without the payload and thus perfect for testing connections (but not it's main purpose and some sites don't support it).