[5.4] Allow PATCH /api/users/id without the need to specify 'groups' in the payload#46750
[5.4] Allow PATCH /api/users/id without the need to specify 'groups' in the payload#46750muhme merged 6 commits intojoomla:5.4-devfrom
Conversation
|
@OctavianC Is this PR a bug fix or a new feature? I‘m asking because the initial issue was labeled as feature request. |
|
In my honest opinion this is a bug - the PATCH request should allow the API to modify user data without the need to specify the |
|
I have tested this item ✅ successfully on 1bb91c7 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46750. |
|
;( PR Test Unsuccessful... CAN'T match BEFORE condition If I try a GET https://www.domain.com/_j540/api/index.php/v1/users/265, I get the user data no problem... { 400 Bad Request... |
|
@exlemor I can only replicate this error message when I'm trying to PATCH my own user ID. This PR does not address this issue so please test the PATCH request to another user ID (= different than the one the API key belongs to) |
|
@OctavianC Not really a good idea to trigger a branch update when that is not really necessary (e.g. due to conflicts). Any new commit (including a branch update) resets the human test counter in the issue tracker, which makes it then impossible to find a PR when checking for number of tests, e.g. to see when it has 2 good tests so we can set it RTC. I have to restore @alikon 's test result in the issue tracker now. |
|
Didn't know that. |
@OctavianC All ok. In general it is not a problem when a PR's branch is shown as outdated to the base branch on GitHub. Only when GitHub shows conflicts it needs to do something. |
|
I have tested this item ✅ successfully on 8ffa857 OK, so:
400 Bad Request... as stated above
It OVERWRITES the User's Data WITHOUT the PR completely with: { It OVERWRITES the User's Data WITH the PR applied complete with: (the User ID moved up 1 because it was a new user which makes sense)
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46750. |
|
@richard67 you are correct, I meant to select Unsuccessful, I tried to Alter Test to Unsuccessful and it shows in Joomla Issue Tracker now as altered to Unsuccessful but not on Github. I'll update the test result now with what I found. |
|
@exlemor You have to use the „Test this“ button again, not the „Alter test“. |
|
I have tested this item 🔴 unsuccessfully on 8ffa857 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46750. |
|
Please provide more details on what payload you are using, what is the API URL and request method and what exactly is being overridden as I'm not sure I understand what the issue is. |
Hi @OctavianC, lesson learned, I am using Postman and when you spin up postman, open up the Joomla Workspace and select the "Joomla Web Services Collection for Postman" collection and then choose: 14. Users --> 14.1 Users --> PATCH users/{user_id}, it opens up the right hand interface to Authorization to which I choose Bearer Token and I put in my Joomla API Token, it (Postman) automatically put in the Body Tab, the payload of: {"email":"new@example.org","groups":["2"],"name":"name","username":"username"} which explains why via PATCH it overwrites the user data... I have replaced that default text and put what is in your screenshot and it works - sorry for not having seen that. |
|
I have tested this item ✅ successfully on 8ffa857 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46750. |
|
Thanks for testing! |
|
RTC This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46750. |
|
✅ Final test before merge with JBT
|
|
Thank you @OctavianC for your contribution. Thank you @alikon and @exlemor for testing. |

Pull Request for Issue #38277 .
Summary of Changes
Adds (if not already present in the payload) the groups array to allow PATCH requests without the explicit need of supplying the user groups
Testing Instructions
See #38277 and related #46732
Actual result BEFORE applying this Pull Request
Save failed with the following error: You can't save a user account without selecting at least one user group.

Expected result AFTER applying this Pull Request
Successful request

Link to documentations
Please select:
No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
No documentation changes for manual.joomla.org needed