Security

Why does creating a user with multiple roles fail when calling the REST API endpoint from curl?

rpwawa
Explorer

I can successfully create users by calling the REST API authentication/users endpoint from curl, but when I try to create a user with multiple roles it fails.

For example, this command will successfully create a user:
curl -k -s -u admin:changeme https://splunk1:8089/services/authentication/users -d name=test1 -d password=test1 -d realname="Test User 1" -d email=test1@here.com -d roles="role1" -d defaultApp=search

However, when I try to specify multiple roles as shown below the command fails. I have tried using a blank, comma and a comma/blank as delimiters between the role names and none of them work.
curl -k -s -u admin:changeme https://splunk1:8089/services/authentication/users -d name=test1 -d password=test1 -d realname="Test User 1" -d email=test1@here.com -d roles="role1,role2" -d defaultApp=search

The REST API documentation for the authentication/users endpoint says that the roles parameter should contain "One or more existing roles to assign to this user."

What syntax should I use for specifying multiple roles when creating a user with the REST API?

Tags (4)
0 Karma
1 Solution

frobinson_splun
Splunk Employee
Splunk Employee

Hi @rpwawa,
I am not sure that "roles" accepts comma separated lists of roles. Can you try submitting roles separately for this user in your request, as in
-d roles="role1", -d roles="role2"

Let me know if this doesn't work and I can do some more research into what's going on...

Hope this helps!

View solution in original post

frobinson_splun
Splunk Employee
Splunk Employee

Hi @rpwawa,
I am not sure that "roles" accepts comma separated lists of roles. Can you try submitting roles separately for this user in your request, as in
-d roles="role1", -d roles="role2"

Let me know if this doesn't work and I can do some more research into what's going on...

Hope this helps!

rpwawa
Explorer

Yes, submitting the roles as separate items works - like this: -d roles="role1" -d roles="role2"

Thanks a lot !!!

frobinson_splun
Splunk Employee
Splunk Employee

awesome! I'll update the docs to mention this. Will convert my comment to an answer as it solved your question. Please feel free to accept it! 🙂

0 Karma
Get Updates on the Splunk Community!

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...