I am helping a member set up some VBA to execute a series of web queries. The URL is for a site that offers a free service to look up hardware MAC addresses. An example URL is
http://www.macvendorlookup.com/api/AZSPMzJ/00:01:29:A4:CA:E0
The last component is the MAC address; the next-to-last component is my API key. You need an API key to make the call but they are available for free registration.
If I enter this into the address box of my browser I get this expected result:"000129000000-000129FFFFFF","Dfi Inc.","100, Huan-ho Street","","Hsi-chih City Taipei Hsien","Taiwan, Province Of China"
However, if I use it in Excel to create a web query, or use VBA code to make a GET call, I get this result:Error: API key not found. Have you registered?
I only have one theory but not sure how to test it. Does Excel send the MAC address in the HTTP header, like a browser would? I am wondering if the site requires the MAC address of the submitting machine to match the one used when I registered for the key. If Excel does not send the MAC address then the site may reject my call as above. I am not familiar with the underlying implementation of how Excel does this.
The following is the VBA code I am using:
Function GetValue(mac As String) As String
With CreateObject("MSXML2.XMLHTTP")
.Open "GET", "http://www.macvendorlookup.com/api/AZSPMzJ/" & mac
.send
Do
DoEvents
Loop Until .readyState = 4
GetValue = .responseText
.abort
End With
End Function
Bookmarks