HTTP Binding : Authentication challenge without WWW-Authenticate header Warning and no data is recovered

Hi,

Using HTTP Binding with multiple headers
Following curl works
curl -X GET --header ‘Accept: application/json’ --header 'PHASH: ’ --header 'UHASH: ’ 'https://api.studer-innotec.com/api/v1/installation/synoptic/6493’](https://api.studer-innotec.com/api/v1/installation/synoptic/6493’

Http biding code
UID: http:url:8b51e0a6fb
label: HTTP URL Thing
thingTypeUID: http:url
configuration:
authMode: BASIC
ignoreSSLErrors: true
headers:
- PHASH=’’
- UHASH=’’
- Accept=‘application/json’
baseURL: https://api.studer-innotec.com/api/v1/installation/synoptic/6493
delay: 0
stateMethod: GET
refresh: 10
commandMethod: GET
contentType: application/json
timeout: 9000
bufferSize: 2048
channels:

  • id: EnergyPower
    channelTypeUID: http:string
    label: Energy Power
    description: “”
    configuration:
    mode: READONLY
    stateTransformation: JSONPATH:$.energy.gridGenset

Getting following error

2021-11-05 16:48:22.545 [WARN ] [p.internal.http.HttpResponseListener] - Requesting ‘https://api.studer-innotec.com/api/v1/installation/synoptic/6493’ (method=‘GET’, content=‘null’) failed: HTTP protocol violation: Authentication challenge without WWW-Authenticate header

Any help please

Did you try BASIC_PREEMPTIVE instead of BASIC?

Tried all the three same result

openhab> bundle:list -s |grep http
71 │ Active │ 80 │ 3.4.3 │ org.apache.cxf.cxf-rt-transports-http
173 │ Active │ 80 │ 3.1.0 │ org.openhab.core.io.http
174 │ Active │ 80 │ 3.1.0 │ org.openhab.core.io.http.auth
275 │ Active │ 80 │ 3.8.1.1 │ org.apache.servicemix.bundles.okhttp
278 │ Active │ 80 │ 3.1.0 │ org.openhab.binding.http
openhab>

Any help please

Did you configure username/password?

There is no userid and password for accessing that api (well itis given as hased value as part of header – which was provided)

Please set the log level to TRACE and show what is actually send.

And please do the request with curl again with -v option.

2021-11-13 00:42:46.261 [TRACE] [ttp.internal.http.RefreshingUrlCache] - Sending to ‘https://api.studer-innotec.com/api/v1/installation/synoptic/6493’: Method = {GET}, Headers = {Accept-Encoding: gzip, User-Agent: Jetty/9.4.40.v20210413, Accept: “application/json”, PHASH: “”, UHASH: “”}, Content = {null}
2021-11-13 00:42:46.372 [TRACE] [p.internal.http.HttpResponseListener] - Received from ‘https://api.studer-innotec.com/api/v1/installation/synoptic/6493’: Code = {401}, Headers = {Cache-Control: no-cache, Pragma: no-cache, Expires: -1, Server: Microsoft-IIS/10.0, X-AspNet-Version: 4.0.30319, X-Powered-By: ASP.NET, Access-Control-Allow-Origin: *, Access-Control-Allow-Headers: Content-Type, PHASH, UHASH, Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS, Date: Fri, 12 Nov 2021 23:42:45 GMT, Content-Length: 0}, Content = {null}
2021-11-13 00:42:46.374 [WARN ] [p.internal.http.HttpResponseListener] - Requesting ‘https://api.studer-innotec.com/api/v1/installation/synoptic/6493’ (method=‘GET’, content=‘null’) failed: HTTP protocol violation: Authentication challenge without WWW-Authenticate header

Working curl
curl -X GET --header ‘Accept: application/json’ --header 'PHASH: --header ‘UHASH: c3ead175e804ff1772c8a9b3f4720bd23f2abfb8738c745d2edfc60c5b98528e’ ‘https://api.studer-innotec.com/api/v1/installation/synoptic/6493

Thanks for the help – just changed the header to the below and it worked

configuration:
authMode: BASIC
headers:
- Accept=‘application/json’
- PHASH=
- UHASH=
ignoreSSLErrors: false
baseURL: https://api.studer-innotec.com/api/v1/installation/synoptic/6493

THANKS A TON