PNO
June 8, 2021, 7:09pm
1
Infos:
Delete method:
https://support.combase.de/api/v1/users/6010
Expected behavior:
something like 200 and user deleted…
Actual behavior:
{
“error”: “Can’t delete, object has references.”,
“error_human”: “Can’t delete, object has references.”
}
What are the references, please? Thank you…
Is it possible that you have tickets for the user?
I think you must delete alle tickets (references) in the 1st step and then the user in a 2nd
PNO
June 10, 2021, 6:28am
3
Hi, that is rather impossible… it is just a user I created a second ago (before trying to delete him) for testing purpose… Unless some tickets are created on default after user is created…
Update: I just verified that the user in question has no tickets assigned to him…
You can’t remove the blocking references via API as they’re much deeper than it’s helping.
This is working as intended - see:
opened 10:08AM - 13 Jun 19 UTC
closed 12:33PM - 08 Dec 20 UTC
works as designed / wontfix
<!--
Hi there - thanks for filing an issue. Please ensure the following things … before creating an issue - thank you! 🤓
Since november 15th we handle all requests, except real bugs, at our community board.
Full explanation: https://community.zammad.org/t/major-change-regarding-github-issues-community-board/21
Please post:
- Feature requests
- Development questions
- Technical questions
on the board -> https://community.zammad.org !
If you think you hit a bug, please continue:
- Search existing issues and the CHANGELOG.md for your issue - there might be a solution already
- Make sure to use the latest version of Zammad if possible
- Add the `log/production.log` file from your system. Attention: Make sure no confidential data is in it!
- Please write the issue in english
- Don't remove the template - otherwise we will close the issue without further comments
- Ask questions about Zammad configuration and usage at our mailinglist. See: https://zammad.org/participate
Note: We always do our best. Unfortunately, sometimes there are too many requests and we can't handle everything at once. If you want to prioritize/escalate your issue, you can do so by means of a support contract (see https://zammad.com/pricing#selfhosted).
* The upper textblock will be removed automatically when you submit your issue *
-->
### Infos:
* Used Zammad version: 3.0
* Installation method (source, package, ..): any
* Operating system: any
* Database + version: any
* Elasticsearch version: any
* Browser + version: Postman and Curl (for direct testing of the endpoints)
* Ticket-ID: #1077545
### Expected behavior:
When having no references (except for ActivityStream and CTI-Stuff), you can delete a user via API endpoint as statet in our documentation: https://docs.zammad.org/en/latest/api-user.html#delete . This will work, even if the user logged in at some point of the accounts lifetime.
If the user has e.g. a ticket he's customer in, you won't be able to delete the user, as there are references that are blocking your way.
### Actual behavior:
When deleting a user via API endpoint, this will only work if the user **never** logged in into Zammad. As soon as you logged in, the following function line will stop you: https://github.com/zammad/zammad/blob/develop/app/controllers/users_controller.rb#L317
Funfact: Even though it says "I got references I can't ignore", you can go to command line and use `.destroy` to delete the user (without problems) as long as the user doesn't have other references like tickets.
Expected API-Output:
`{}`
Received API-Output:
```json
{
"error": "Can't delete, object has references."
}
```
If you remove or comment out Line 317 of users_controller.rb, it will work.
If you have e.g. ticket references, you'll receive such a (maybe ugly) response:
```json
{
"error": "PG::ForeignKeyViolation: ERROR: update or delete on table \"users\" violates foreign key constraint \"fk_rails_5e0981116b\" on table \"activity_streams\"\nDETAIL: Key (id)=(20) is still referenced from table \"activity_streams\".\n: DELETE FROM \"users\" WHERE \"users\".\"id\" = $1"
}
```
### Steps to reproduce the behavior:
* Create a customer user without tickets (if you create some, you'll need to delete them first ;) )
* Take over the view of the customer or login as customer
* log out / go back
* take your favorite API-Endpoint tool and try to delete the new user: `https://myzammad.tld/api/v1/users/{User-ID}`
This will not work, while a `u=User.find({User-ID}` followed by `u.destroy` will work.
Yes I'm sure this is a bug and no feature request or a general question.
system
Closed
November 13, 2021, 12:01pm
5
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.