0

I am using the code below to call an API (for Harvest, a timekeeping web app). It works fine on my machine for two different users, but when run on a different machine, it does not work for either user. (And when I say "works," it returns a valid XML file of results on my machine, and on the other machine it returns an empty file with an authentication error message.) Both machines are on Excel 2010. Is there something machine-specific that could impact the encoding?

'Set up the HTTP headers so Harvest will interpret this as an API request.
httpReq.setRequestHeader "Content-Type", "application/xml"
httpReq.setRequestHeader "Accept", "application/xml"
httpReq.setRequestHeader "Authorization", "Basic " + Base64Encode(user + ":" + pass)
httpReq.send
Ben Rhys-Lewis
  • 3,118
  • 8
  • 34
  • 45
rryanp
  • 1,027
  • 8
  • 26
  • 45
  • this is a shot in the dark, but this `Base64` makes we wander if the machines are 32 v 64 bit? – Scott Holtzman Jan 26 '16 at 18:03
  • What's in the `Base64Encode` function ? Is that working correctly on the problem PC's ? – Tim Williams Jan 27 '16 at 07:13
  • Great thoughts--thanks! It turns out both machines are 64-bit Windows 7. Tim, I will dig into that Base64Encode function...I'm not sure how to test it individually but I'll look into it. I found in the code comments that function was borrowed from another SO post (just to give full credit): http://stackoverflow.com/questions/496751/base64-encode-string-in-vbscript Thank you both! – rryanp Jan 27 '16 at 15:40
  • You can test the encoding function using (eg)`Debug.Print Base64Encode("Hello World")` which should give `SGVsbG8gV29ybGQ=` according to https://www.tools4noobs.com/online_php_functions/base64_encode/ – Tim Williams Jan 27 '16 at 21:52

0 Answers0