REST API - User / Organization Update - index from an attribute instead of id

Infos:

Used Zammad version: 2.3.x
Used Zammad installation source: DEB
Operating system: Ubuntu 16.04 LTS
Browser + version: Chrome Version 63.0.3239.132

Expected behavior:

  • editing a user using an attribute

Actual behavior:

  • based on rest api doku, only with ID possible

Steps to reproduce the behavior:

I have created organizations with a customer number (debnumber is a custom attribute I have added)
Using these attributes (debnumber) I want to import users with rest api and assign them to the respective organization.

The users also have this attribute (default number).
In the DOKU it says “PUT /api/v1/users/{id}” with the “update” - but I don’t have this ID, but the one (debnumber).

If this is possible, i. e. summarized again: My organizations have a unique number (double number) and my user database contains it as well. Now a comparison of these should take place during the import, so that users with the debnummer=3 are added to the company with the debnummer=3.

How can I do this? The actual import via curl and json is clear to me, it’s all about the assignment-

Hey, when I understand you right you could maybe use this:

/api/v1/users/search?query=debnumber:1
This gives you every user with the debnumber 1

You get all the user ids and the organization number they should belong

after this you search for the organization number and get the organization id

/api/v1/organizations/search?query=debnumber:1

after this you could make a put for the user and give him the right organization id

Thanks for your answer!

I’m glad that I was able to help you.

One more hint, maybe you have to use the pagination or limit if you want to use it in a script and for many people.

Cheers

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.