We are trying to establish connection to the RESTful web service to get real-time vehicle location information. We use foxpro application and WEB connection library to submit requests. 2 requests has to be sent:
- Token API call to get authetication token
- GET location API call to receive vihicle location
First call goes trough fine, we are able to get token. But second request is failing with the resultcode 401. I can see that authorization header is correct, it contains valid token. But for some reason it is failing.
Could you suggest what is wrong with this request.
DO wwhttp
loHttp = CREATEOBJECT("wwHttp")
*** Token Request*****
loHttp.cHttpVerb = "GET"
loHTTP.AddHeader("Accept","plain/text")
lcToken = loHttp.HttpGet(lcBaseUrl, lcUserName, lcPassword)
*** Vehicle Location Request***
loHTTP.AddHeader("Accept","application/json;")
lcHeader = "Atmosphere atmosphere_app_id=fleetmatics-p-us-1yHt6zjNk3G6gFjUUQsKRf1w, Bearer "+lcToken
loHTTP.AddHeader("Authorization",lcHeader)
lcResponse = loHTTP.HTTPGet(lcBaseUrl)
If you're sending custom Authorization
headers make sure you turn off all authentication in IIS for your site or virtual or you use a proper auth prefix (Basic Negotiate Bearer etc.) that should ensure it's bypassing Basic or Negotiate for Basic and WIndows Auth respectively.
Bearer 123456789x
Most likley either IIS Windows or Basic Auth is getting to your request before your app gets to it.
+++ Rick ---
Is there a way around it? Another pieces of information - when we were using web interface to test those requests it worked in Chrome and Firefox. But IE was giving the same error.
Also we are not hosting this site, it is an outside call. So looks like we need to look at authorization prefix. How to ensure that Basic will be bypassed?