Power Automate - HTTP 301- Moved Permanently error

Recently for one of the Power Automate use cases, I was trying to get the details from a public MS documentation URL with the help of HTTP action in the Power Automate flow.

But while getting the content for the URL “https://learn.microsoft.com/en-us/connectors/azureloganalytics”, it threw the exception, which was HTTP 301 error.

HTTP 301 (Moved Permanently) error states that the requested URL location is moved to the URL given by the Location headers.

HTTP

To resolve the issue, I first tried the obvious workaround to use the header’s location property (URL) received from the output of the first HTTP action (failed action) in the second “HTTP – Try again” action.

actions('HTTP').outputs.headers.Location

But in my case, the output of the first HTTP action returned me the sanitized URL in the header’s location property, and the second HTTP action failed as well with the BadRequest error.

BadRequest Error

After some more digging, I finally found the root cause of the issue.

The problem was in the URL of the first HTTP action. The URL used in the first HTTP action was missing the “/” (forward slash) at the end of the URL.

After adding the missing / (forward slash) at the end of the URL in the first HTTP action, the HTTP action succeeded, and it returned a success status code of 200 along with the web content.

Url: “https://learn.microsoft.com/en-us/connectors/azureloganalytics/”

Happy Learning, Anywhere!