I have one macro that I used to test access to https://www.dropbox.com/ and it worked for three years. But, about December 15-16, it stopped: it always gives out a HTTP status code = 400! It reacts normally to a dozen other services. I've been fighting for 5 days, friends helped, but... Can you share your ideas?
Here is the function ('the function checks for access to the URL $ resource (file or directory)
'returns the server response code (number), or 0 if the link is invalid
'(200 - resource available, 404 - not found, 403 - no access, etc.):
Public Function GetURLstatus(ByVal URL$) As Long
On Error Resume Next: URL$ = Replace(URL$, "\", "/") Set xmlhttp = CreateObject("Microsoft.XMLHTTP") xmlhttp.Open "GET", URL, "False" xmlhttp.setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT" xmlhttp.send GetURLstatus = Val(xmlhttp.Status) Set xmlhttp = Nothing End Function
a fragment of a macro where this function is used:
URL$ = "https://dropbox.com/" 'directory link If GetURLstatus(URL$) = 200 Then........
I recommend checking the body of the error response. It may contain a more useful error message or error page.
For instance, the Dropbox web site recently dropped support for Internet Explorer 11, so if your HTTP client is setting a User-Agent that appears to be Internet Explorer 11, the Dropbox web site will now return an error page indicating that it is no longer supported.
In that case, you could fix this by updating your code to not set a User-Agent string that appears to be Internet Explorer. (I can't provide support for VBA or Microsoft.XMLHTTP, but you might be able to set the "User-Agent" header via the "xmlhttp.setRequestHeader" method, like you're using to set your "If-Modified-Since" header.)