curl 8.14 auth error

All kinds of 'OS' scripts

Moderator: leecollings

Post Reply
iagovagge
Posts: 2
Joined: Monday 06 April 2026 8:33
Target OS: Linux
Domoticz version:
Contact:

curl 8.14 auth error

Post by iagovagge »

Ciao

i have a script with a curl request to domoticz like this

curl -H "Authorization: Basic [***]" -k --data "type=command&param=getdevices&rid=[iddevice*]" https://[*fqdn*]/json.htm? | jq '.result[0].Level'

domoticz is behind an apache2 reverse proxy

the script still works great in pc with debian bookworm or previous (curl <= 7.88) but doesn't work in pc with debian trixie (curl = 8.14) with an 401 authorization error

can someone help me
User avatar
jvdz
Posts: 2482
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: curl 8.14 auth error

Post by jvdz »

When Authentication is done by domoticzs,you need to change the basic authentication, as that support is dropped, to https//userid:password@rest_url.
User avatar
gizmocuz
Posts: 3026
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: curl 8.14 auth error

Post by gizmocuz »

Also try to see if this solves the issue

Code: Select all

curl -L --location-trusted -H "Authorization: Basic ..." -k \
  --data "type=command&param=getdevices&rid=..." \
  https://fqdn/json.htm?
or

Code: Select all

curl -u user:pass -k \
  --data "type=command&param=getdevices&rid=..." \
  https://fqdn/json.htm?
Quality outlives Quantity!
iagovagge
Posts: 2
Joined: Monday 06 April 2026 8:33
Target OS: Linux
Domoticz version:
Contact:

Re: curl 8.14 auth error

Post by iagovagge »

try all suggestions but still not work with 401 Unauthorized error. All this command work in curl 7.88
User avatar
gizmocuz
Posts: 3026
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: curl 8.14 auth error

Post by gizmocuz »

You enabled basic authentication in Domoticz? And using https?
Do you have any special characters in your username/password that needs to be escaped?
Quality outlives Quantity!
iagovagge
Posts: 2
Joined: Monday 06 April 2026 8:33
Target OS: Linux
Domoticz version:
Contact:

Re: curl 8.14 auth error

Post by iagovagge »

doesn't work with basic authentication enabled in Domoticz and url http:[*ip*]:8080/json.htm? in curl 8.14... work with 7.88
use a username/password without special characters that needs to be escaped

seem a change in curl that need something new in the command but can't find any help in change log
Last edited by iagovagge on Friday 10 April 2026 22:09, edited 1 time in total.
User avatar
gizmocuz
Posts: 3026
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: curl 8.14 auth error

Post by gizmocuz »

Do you use HTTP or HTTPS? Try HTTPS (port 443 or no port by default)
Quality outlives Quantity!
iagovagge
Posts: 2
Joined: Monday 06 April 2026 8:33
Target OS: Linux
Domoticz version:
Contact:

Re: curl 8.14 auth error

Post by iagovagge »

@gizmocuz i try your command (on monday 6 post) with https and with and without port
work on curl 7.88 but not with curl 8.14
Last edited by iagovagge on Saturday 11 April 2026 17:30, edited 1 time in total.
User avatar
gizmocuz
Posts: 3026
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: curl 8.14 auth error

Post by gizmocuz »

Investigation Result: curl 8.14 Basic Auth 401

Root cause

The Domoticz webserver (libwebem) decides whether to accept a Basic Auth header by checking whether the URI contains
/json.htm? (with a question mark):

The problem with the original command

The user's command:
curl --data "type=command&param=getdevices&rid=[id]" https://[fqdn]/json.htm?

--data makes a POST request. The parameters go into the request body — the URL itself is just https://host/json.htm?
with an empty query string. The HTTP request line sent to the server is:

POST /json.htm? HTTP/1.1

If curl 8.14 normalizes the empty trailing ? away (empty query strings have no semantic meaning in RFC 3986), the
server receives:

POST /json.htm HTTP/1.1

Then req.uri.find("/json.htm?") returns npos → Basic Auth is silently ignored → 401.

This also explains why all the suggested alternatives failed — they all still used --data (POST) with the same
trailing-? URL. The Authorization header was fine; the URI matching was the actual blocker.

The fix

Stop using --data for the Domoticz JSON API. The API is a plain GET endpoint — put the parameters in the URL:

Code: Select all

  curl -u user:pass -k \
    "https://[fqdn]/json.htm?type=command&param=getdevices&rid=[id]" \
    | jq '.result[0].Level'
Or with an explicit header:

Code: Select all

  curl -H "Authorization: Basic [base64]" -k \
    "https://[fqdn]/json.htm?type=command&param=getdevices&rid=[id]" \
    | jq '.result[0].Level'
With params in the URL, the URI the server sees is /json.htm?type=command&... which definitely contains /json.htm?, so
Basic Auth is accepted correctly regardless of curl version.
Quality outlives Quantity!
iagovagge
Posts: 2
Joined: Monday 06 April 2026 8:33
Target OS: Linux
Domoticz version:
Contact:

Re: curl 8.14 auth error

Post by iagovagge »

Great! your fix works!
probably curl 8.14 delete "?" correctly vs 7.88 leave it and Domoticz webserver accept URI with /json.htm?

thanks fro your time and attention
Last edited by iagovagge on Sunday 12 April 2026 15:22, edited 1 time in total.
Post Reply