Web Connection
httpGet - failing authorization
Gravatar is a globally recognized avatar based on your email address. httpGet - failing authorization
  IrinaP
  All
  Feb 23, 2017 @ 10:22am

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:

  1. Token API call to get authetication token
  2. 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)

Gravatar is a globally recognized avatar based on your email address. re: httpGet - failing authorization
  Rick Strahl
  IrinaP
  Feb 23, 2017 @ 05:20pm

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 ---

Gravatar is a globally recognized avatar based on your email address. re: httpGet - failing authorization
  IrinaP
  IrinaP
  Feb 24, 2017 @ 04:37am

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.

Gravatar is a globally recognized avatar based on your email address. re: httpGet - failing authorization
  IrinaP
  IrinaP
  Feb 24, 2017 @ 05:53am

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?

Gravatar is a globally recognized avatar based on your email address. re: httpGet - failing authorization
  IrinaP
  IrinaP
  Feb 24, 2017 @ 07:13am

Rick, thank you for your help. it is working now. I was changing couple of things, not sure what exactly made a difference but it is working !!

© 1996-2017