Mattermost, Inc.

[SOLVED] Create a user via REST API and set it's position

Is there an option to register a user using the REST API and set its position field?

When looking at the API documentation here: https://api.mattermost.com/v4/#tag/users%2Fpaths%2F~1users%2Fpost
I saw a field name called “props”, and it seems to be undocumented. Can I use it to set the user’s position field?

And another question, what is the purpose of “locale” field?

Thank you

No, you cannot, props is like an extra field where you can add customize properties to that user.


This is untested but I just looked at the code and did not see any limitation of parameters for the “create a user” API, have you tried simple adding a property called position to your call and see what happens?


To update the position you need to use a second call update that user with:

https://api.mattermost.com/v4/#tag/users%2Fpaths%2F~1users~1{user_id}%2Fput

locale (usually defined as user’s language) is the language that user will have its UI in, like English (en), etc…

This is untested but I just looked at the code and did not see any limitation of parameters for the “create a user” API, have you tried simple adding a property called position to your call and see what happens?

I have passed a props value of “position” durring user registration but it did not set the position for that user.

Thank you @prixone

Can you provide your current sample code used to register a user? I think it will be faster that way.

@prixone, I am using an external app to send a user create request.

The endpoint is:
http://10.0.0.2:8065/api/v3/users/create

and data object is:
{
“email”: "a@b.net",
“username”: “tester99”,
“first_name”: “A”,
“last_name”: “B”,
“nickname”: “nickname2”,
“password”: “tester99”,
“locale”: “”,
“props”: {“position”: “myPos”}
}

As I had suspected you misunderstood what I said previously.

I said that:

This is untested but I just looked at the code and did not see any limitation of parameters for the “create a user” API, have you tried simple adding a property called position to your call and see what happens?

Which would be this:

{
"email": "a@b.net",
"username": "tester99",
"first_name": "A",
"last_name": "B",
"nickname": "nickname2",
"password": "tester99",
"locale": "",
"position": "myPos"
}

If the above does not work, then you will have to do 2 calls, 1 to create the user and another to update it.

You should also use the v4 endpoint instead of the v3 as the v3 will cease existence soon.


As I said early the “props” is to allow you to create custom properties, not to edit the default existent ones.

Thank you @prixone. It works :slight_smile:

1 Like

Thanks @JH635 and @prixone!

I’ll close this issue off for now…

1 Like