Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.1.4] (and [4.2.0dev3]) - Webservices PATCH to update a user fails with status 400 #37991

Closed
aftertaf opened this issue Jun 5, 2022 · 12 comments

Comments

@aftertaf
Copy link

aftertaf commented Jun 5, 2022

Steps to reproduce the issue

PREREQUISITES THAT I HAVE "validated"

-have a functional Postman Webservices API setup for your site
-validate that the SuperUser token can GET {{base_url}}/{{base_path}}/users/
-validate that PATCH of an existing custom user field: {{base_url}}/{{base_path}}/fields/users/{{field_id}} also works

ISSUE:
Once the above is tested OK, try to update a user with PATCH : {{base_url}}/{{base_path}}/users/{{user_id}}

The attempt to update a user with Postman generates this cURL code snippet:
curl --location --request PATCH 'https://www.mysite.xyz/api/index.php/v1/users/626'
--header 'Content-Type: application/json'
--header 'X-Joomla-Token: SomeRandomTextReplacingMyActualToken'
--data-raw '{"email":"new@example.org"}'

Expected result

In Postman :
-HTTP response 200
-Response of modified user in JSON format

Actual result

In Postman:
-Status : 400 : Bad request
"The request cannot be fulfilled due to bad syntax"

-JSON Body:
{"errors":[{"title":"The passwords you entered do not match. Please enter your desired password in the password field and confirm your entry by entering it in the confirm password field."}]}

System information (as much as possible)

debian 11, PHP 8.0.18, Apache fpm-fcgi
MariaDB - 10.5.15-MariaDB-0+deb11u1

Additional comments

Tested on 4.2.0-alpha3-dev and Joomla! 4.1.4 Stable [ Kuamini ] 24-May-2022 (both sites on same VM)

@toivo
Copy link
Contributor

toivo commented Jun 6, 2022

This is just to confirm that this issue happens with Postman in Joomla 4.1.5-dev using PHP 8.0.15 and Wampserver 3.2.9.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37991.

@alikon
Copy link
Contributor

alikon commented Jun 6, 2022

confirmed

@alikon
Copy link
Contributor

alikon commented Jun 6, 2022

please test #37994

@alikon alikon closed this as completed Jun 6, 2022
@aftertaf
Copy link
Author

aftertaf commented Jun 6, 2022

Latest change by @alikon 14830e8 works :)
thanks !!!

@aftertaf
Copy link
Author

aftertaf commented Jun 6, 2022

I do have another "question", if i may...
Can it be possible to allow a user PATCH API call without needing to specify their groups ?
If I do a PATCH of a UserID with just an Emal update, I get an error message :
"errors": [
{
"title": "Save failed with the following error: You can't save a user account without selecting at least one user group.",
"code": 400
}
]
This means any PATCH to a user needs to GET their group memberships and then rewrite them, which seems a bit illogical if no change to groups is needed or desired.

@alikon
Copy link
Contributor

alikon commented Jun 6, 2022

make sense, pull request are wellcome

p.s
can you please mark a successfull test #37994 on https://issues.joomla.org/tracker/joomla-cms/37994

@aftertaf
Copy link
Author

aftertaf commented Jun 6, 2022

make sense, pull request are wellcome

p.s can you please mark a successfull test #37994 on https://issues.joomla.org/tracker/joomla-cms/37994

Done.. (still learning what needs doing when , etc... thanks for your patience :) )

@aftertaf
Copy link
Author

aftertaf commented Jun 6, 2022

make sense, pull request are wellcome

could you point me towards the file that would need changing ? i could try to change it if I knew which one, ( least I can do :) )

@alikon
Copy link
Contributor

alikon commented Jun 6, 2022

@aftertaf
Copy link
Author

aftertaf commented Jun 6, 2022 via email

@aftertaf
Copy link
Author

aftertaf commented Jun 7, 2022

ok. I've had a look and tried to make a quick fix/workaround.....
disclaimer, I ain't a developer :)
I have tried but got myself a bit tangled...

What's the 'right' way to ask someone else to look at this, and make it possible, when doing an API PATCH call to the USERS API, to not need to send group-related information ?

@alikon
Copy link
Contributor

alikon commented Jun 8, 2022

open a new issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants