Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
PATCH on user to change the user name works fine.
But to change password and email it requires to specify current_password.
I tried to get help on how to pass this value but no response . So I read user module related code tried with "current_pass"
But it fails with 500. Screen shot attached.
Comment | File | Size | Author |
---|---|---|---|
PATCH on USER.png | 56.72 KB | vivekvpandya |
Comments
Comment #2
cilefen CreditAttribution: cilefen commentedThe issue summary needs a rewrite to be more understandable to contributors. I do not understand what this sentence means: "But to change password an email it requires to specify current_password."
Also, there is a mention of a patch, but not reference to an issue number.
Comment #3
cilefen CreditAttribution: cilefen commentedThe issue needs a more descriptive title.
Comment #4
vivekvpandya CreditAttribution: vivekvpandya as a volunteer commentedComment #5
vivekvpandya CreditAttribution: vivekvpandya as a volunteer commented@cilefen
It is about PATCH request on /user via REST full web service to update user details.
I want to change email address and password from my REST client talking to Drupal 8 backend ( All necessary permissions and setup has been done )
So If I make a PATCH request with following JSON
It gives 422 Unprocessable Entity
{
"error": "Unprocessable Entity: validation failed.\nmail: Your current password is missing or incorrect; it's required to change the Email.\n"
}
So to I tried with
Then it gives 500.
So how do I specify current password so that I can change my email ?
Actually this is not issue regarding REST.
I inspect the error logs and I found this
InvalidArgumentException: Field current_pass is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 474 of /Applications/XAMPP/xamppfiles/htdocs/dr8b14/core/lib/Drupal/Core/Entity/ContentEntityBase.php).
So actually current_pass is not correct way to specify current password.
But this message is not getting propagated to REST client . I think it should not give 500.
Comment #6
cilefen CreditAttribution: cilefen commentedOh a PATCH request! Sorry, I misunderstood.
Comment #7
cilefen CreditAttribution: cilefen commentedComment #8
cilefen CreditAttribution: cilefen commentedComment #9
marthinal CreditAttribution: marthinal as a volunteer commentedHi guys,
If you want to change your pass and mail then you need something like this:
Comment #10
marthinal CreditAttribution: marthinal as a volunteer commentedLet me know if it works and probably we can close the issue.
Comment #11
cilefen CreditAttribution: cilefen commented@marthinal Is this something that needs documenting somewhere?
Comment #12
marthinal CreditAttribution: marthinal as a volunteer commented@cilefen Well I think we could add this info to the REST doc. It will be really helpful :) I can do it later today.
Comment #13
vivekvpandya CreditAttribution: vivekvpandya as a volunteer commented@marthinal
Thanks !
It worked .
Comment #14
vivekvpandya CreditAttribution: vivekvpandya as a volunteer commented@marthinal and @cilefen I think the error reporting to the client side can be improved because in my previous attempt it just got crashed with 500.
And Is there any plan to make a document for REST module API for Drupal 8 ? It would be better if we make something similar to document available for Twitter's REST API.
Please let me know if I can help in that .
Comment #15
marthinal CreditAttribution: marthinal as a volunteer commentedAdded doc about it.
[#2558697]
@vivekvpandya About internal error 500... yes, I think it should be 400 (Bad request) because your request is not correct. When creating a new user from anonymous and adding a field that does not exist, I receive a 500 but the user is created as expected. I need to investigate a little bit more and maybe create a new issue about it. Feel free to investigate and contribute :)
If you want to contribute with the doc I think the place is https://www.drupal.org/documentation/modules/rest
Many thanks for contributing!!!!
Comment #16
clemens.tolboomDocumentation page is here
Comment #17
klausi