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

Update user not working #202

Open
timnis opened this issue Mar 15, 2023 · 1 comment
Open

Update user not working #202

timnis opened this issue Mar 15, 2023 · 1 comment
Assignees
Labels
documentation Issues that concern documentation

Comments

@timnis
Copy link

timnis commented Mar 15, 2023

  • Zammad API Client version: 2.0.1
  • Python version: 3.11
  • Operating System: fedora 37
  • Zammad Version: 5.4.0

Description

Connected to Zammad 5.4.0 with token and token has admin.user permission.

Trying to update user but do nothing

What I Did

from zammad_py import ZammadAPI

zm = ZammadAPI(url='https://xxxx.com/api/v1/', http_token='xxxx')

timo = zm.user.find(4)
params = {'firstname':'Timoo'}
timo.update(params=params)

timo = zm.user.find(4)
print(timo)

Testing with curl works .

curl -H "Authorization: Token token=xxxx" https://xxxx.com/api/v1/users/4 -X PUT -H 'Content-Type: application/json' --data-binary '{"firstname": "Timoo"}'
@timnis timnis changed the title Update not working Update user not working Mar 15, 2023
@Anuril Anuril self-assigned this Apr 12, 2023
@Anuril
Copy link
Collaborator

Anuril commented Apr 12, 2023

Hi,
This is more of a documentation issue, specifically, because I overlooked it when I updated it.

As the zammad_py package is still basically a wrapper for the api, and doesn't provide model instances, find() will return a dict.

To update records, you need to instead do this:

`from zammad_py import ZammadAPI

zm = ZammadAPI(url='https://xxxx.com/api/v1/', http_token='xxxx')

timo = zm.user.find(4)
timo['firstname'] = 'Timoo'
zm.user.update(id=timo['id'],params=params)

timo = zm.user.find(4)
print(timo)`

I'll update the documentation to reflect this, thanks for your feedback!

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

No branches or pull requests

2 participants