Invoke power shell activity for getting status code of the URL if it works and if URL failed means need to get the failed description

@dany_khanth
Have a look on the different options and its behaviour:

Powershell:

Visuals

Script:

try
{
  $status = wget $url | % {$_.StatusCode.ToString()}
}
catch [exception]
{
   $status = $_.Exception.Message.ToString()
}

Flow:
grafik

Details:

HTTP Activity:

Visuals


grafik

HttpWebRequest API / UiPath

Visuals

myHttpRequest2 = CType(WebRequest.Create(strURL), HttpWebRequest)
myResponse = CType(myHTTPRequest2.GetResponse, HttpWebResponse )
String.Format("Status Form Code HTTPRequest: StatusCode: {0} - Description {1}", CInt(myResponse.StatusCode).toString,myResponse.StatusDescription)

Variables:
grafik

When running different cases we get following:
URL OK
grafik
URL not existing
grafik
Invalid Url
grafik

Fazit:

  • we can do it with Powershell, but also can do it within UIPath
  • HTTP Request Activity is limited for second case and has Status 0
  • HTTP Request Coding (Option 3) is close to the Powershell

Find starter Help here:
CheckURL.xaml (12.4 KB)
CheckURL.ps1.txt (139 Bytes)