Preventing a Redirect on API call - Grabbing headers before a redirect
Channel: AUTOHOTKEY Gurus
Date: 2021-07-30

RaptorX and I were working on a script with an API Call (WinHTTPRequest).  We were getting some weird results so we started using Fiddler and playing with headers.  Some valuable lessons learned!

TLDR: The video provides tips and solutions for troubleshooting HTTP errors and improving automation processes.

1. 00:00 🔍 The Automator team faced an issue with an HTTP request, but ultimately succeeded in retrieving the desired webpage.
 1.1 The Automator team encountered a conundrum while using an HTTP request to grab a specific page on the documentation, but were able to resolve it and successfully retrieve the webpage.

2. 01:19 🚨 A capitalization difference caused an issue, but it was fixed by formatting strings to be lowercased.
 2.1 The issue was caused by a difference in capitalization between two strings being compared, which was resolved by formatting them to be lowercased.
 2.2 The browser automatically redirects to the correct site, but the script is not doing automatic redirection.

3. 03:40 🚀 SpaceX successfully launched and landed its Falcon 9 rocket carrying 60 Starlink satellites.
 3.1 To handle empty responses, set it to false and manually redirect by looking for the location header and doing a request on it instead.

4. 05:13 🔍 LinkedIn server issues resolved by adding pause option to redirect and performing additional request check.
 4.1 Adding option six to pause the redirect helped Jackie and the speaker resolve issues with LinkedIn's server response.
 4.2 The browser sends another request on its own if the winning request doesn't act on it, but it cancels it if it's not the correct request, and the browser intelligently double checks where it's supposed to go without the user realizing it.
 4.3 If you have the option to stop the first request, perform a check for an empty header and do another request based on the location header.

5. 07:55 🚨 An incorrect URL caused an error message with little information, but checking the browser headers helped to identify the problem.
 5.1 The issue was caused by an incorrect URL, and the lack of information provided by the error message made it difficult to diagnose, but checking the headers in the browser helped to identify the problem.

6. 09:24 🔍 To troubleshoot HTTP errors, check the status code and disable redirects, then use the "get all response headers" method to find the correct document location.
 6.1 The lecture discusses troubleshooting HTTP requests by checking the status code and disabling redirects.
 6.2 To troubleshoot a particular error, set up the option to false and check the status code, which should be 301 indicating that the document was moved.
 6.3 To find the correct document location, use the "get all response headers" method and look for the "location" header.

7. 12:45 📰 A website has moved permanently, use a while loop to continuously redirect to the new location until the desired web page is reached.
 7.1 To handle a 301 status code, get the location and open it again, then use http.send to get the response text.
 7.2 Use a while loop to continuously redirect to the next location until the desired web page is reached, while setting the "do not redirect" option and obtaining the correct URL.

8. 15:20 💻 Take the intermediate Autohotkey course to advance your skills.
 8.1 Take the intermediate Autohotkey course to learn more advanced features and work through it systematically.

If you're new to AutoHotkey and want to learn amazing tips & tricks Check out this Amazing AutoHotkey Tutorial for Beginners: https://www.youtube.com/watch?v=hZRggm8RkhM