Problem using pwg.images.getInfo with the X-PIWIGO-API header - Missing parameters: image_id #2226

Closed
opened 2026-10-05 01:10:23 +02:00 by adam · 2 comments
Owner

Piwigo version 16.4.0
I am migrating my PiwigoPublish-lrc-plugin to use the X-PIWIGO-API header for authentication and have hit what I think is a bug in the pwg.images.getInfo API endpoint

When I call it via GET without the header it works fine.
When I call via GET it with a valid API key in the header it returns "err":1002,"message":"Missing parameters: image_id"
When I call via GET it with an invalid API key in the header it returns "err":401,"message":"Invalid api_key"
I have tested this in a terminal using CURL

curl -G "https://mypiwigohost/ws.php" \
  --data-urlencode "method=pwg.images.getInfo" \
  --data-urlencode "format=json" \
  --data-urlencode "image_id=123" \
  -H "X-PIWIGO-API: pkid-...:..."

If I switch from GET to POST (via the API explorer) the endpoint works correctly.

I have done similar tests calling pwg.categories.getList and that appears to work correctly whether or not the X-PIWIGO-API header is set.

curl -G "https://mypiwigohost/ws.php" \
  --data-urlencode "method=pwg.categories.getList" \
  --data-urlencode "format=json" \
  --data-urlencode "cat_id=24" \
  -H "X-PIWIGO-API: pkid-...:..." 

I have tried on two different instances of Piwigo, both running 16.4.0, and got the same result on each.


php --version
PHP 8.1.2-1ubuntu2.25 (cli) (built: Jul 16 2026 18:32:33) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.25, Copyright (c), by Zend Technologies

I know that pwg.images.getInfo can be run without authentication but it behaves differently to other endpoints that can also be run without authentication (e.g. pwg.categories.getList) and so I think there is a bug somewhere.

Piwigo version 16.4.0 I am migrating my PiwigoPublish-lrc-plugin to use the X-PIWIGO-API header for authentication and have hit what I think is a bug in the pwg.images.getInfo API endpoint When I call it via GET without the header it works fine. When I call via GET it with a valid API key in the header it returns "err":1002,"message":"Missing parameters: image_id" When I call via GET it with an invalid API key in the header it returns "err":401,"message":"Invalid api_key" I have tested this in a terminal using CURL ``` curl -G "https://mypiwigohost/ws.php" \ --data-urlencode "method=pwg.images.getInfo" \ --data-urlencode "format=json" \ --data-urlencode "image_id=123" \ -H "X-PIWIGO-API: pkid-...:..." ``` If I switch from GET to POST (via the API explorer) the endpoint works correctly. I have done similar tests calling pwg.categories.getList and that appears to work correctly whether or not the X-PIWIGO-API header is set. ``` curl -G "https://mypiwigohost/ws.php" \ --data-urlencode "method=pwg.categories.getList" \ --data-urlencode "format=json" \ --data-urlencode "cat_id=24" \ -H "X-PIWIGO-API: pkid-...:..." ``` I have tried on two different instances of Piwigo, both running 16.4.0, and got the same result on each. ``` php --version PHP 8.1.2-1ubuntu2.25 (cli) (built: Jul 16 2026 18:32:33) (NTS) Copyright (c) The PHP Group Zend Engine v4.1.2, Copyright (c) Zend Technologies with Zend OPcache v8.1.2-1ubuntu2.25, Copyright (c), by Zend Technologies ``` I know that pwg.images.getInfo can be run without authentication but it behaves differently to other endpoints that can also be run without authentication (e.g. pwg.categories.getList) and so I think there is a bug somewhere. <!-- github-sync-id:5030063602 -->
adam closed this issue 2026-10-05 01:10:23 +02:00
Author
Owner

Hello @fjb2020 ,

I'll cherrypick this fix into 16.x so it's will be included in the next release (16.5.0). I've put the code below in case you want to apply the fix yourself and not waiting the next release.

include/user.inc.php replace line 81 by:

if (!empty($_POST))
{
    $_POST['pwg_token'] = get_pwg_token();
}
else
{
    $_GET['pwg_token'] = get_pwg_token();
}
Hello @fjb2020 , I'll cherrypick this fix into `16.x` so it's will be included in the next release (16.5.0). I've put the code below in case you want to apply the fix yourself and not waiting the next release. `include/user.inc.php` replace line `81` by: ``` if (!empty($_POST)) { $_POST['pwg_token'] = get_pwg_token(); } else { $_GET['pwg_token'] = get_pwg_token(); } ``` <!-- github-comment-id:5144516987 -->
Author
Owner

Thank you @LintyDev - fix applied and it's now working

Thank you @LintyDev - fix applied and it's now working <!-- github-comment-id:5144620522 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#2226