Splunk Dev

Add user with python SDK

maurelio79
Communicator

Hi, i'm learning Python SDK and i'm try to create a new user, with this code:

users = service.users
new_user = users.create("my user", "empty password", roles="basic_user", type="Splunk")

but i get this error:

raise HTTPError(response)
splunklib.binding.HTTPError: HTTP 400 Bad Request --
In handler 'users': Argument "type" is not supported by this handler.

How to pass the auth type to the class Users? i try in different way, but no one works.

In general, when in api reference i found something like this:

params (dict) – Additional arguments (optional). For a list of available parameters, see User authentication parameters on Splunk Developer Portal.

In which format i have to pass param?

Thanks in advance and regards.

P.S.

I'm trying also:

users = service.users
kwargs = {"type": "Splunk"}
new_user = users.create("wu", "test", roles="user", **kwargs)

But i get the same error

P.P.S.

Ok, this last method is correct, i tried with

kwargs = {"realname": "Some Name"}

and it works. So how can i pass the authetication method to this class?

0 Karma
1 Solution

paramagurukarth
Builder

You can set values only for the following fields

defaultApp
email
force-change-pass
password
realname
restart_background_jobs
roles
tz

View solution in original post

paramagurukarth
Builder

You can set values only for the following fields

defaultApp
email
force-change-pass
password
realname
restart_background_jobs
roles
tz
Get Updates on the Splunk Community!

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...