Unable to create DSS users using shell script
![mettuharish](https://us.v-cdn.net/6038231/uploads/Dataiku/nAvatar2.png)
Hello All,
I have tried creating DSS users by using python script but unable to do it. It throws below error.
#!/bin/bash
DATAIKU_URL="DataIKU URL"
DATAIKU_API_KEY="XXX_API_KEY"
ENDPOINT="/users"
PAYLOAD='{
"id": "hamett0",
"displayName": "Harish Kumar Mettu",
"password": null,
"sourceType": "LDAP",
"groups": ["administrators"],
"profile": "PLATFORM_ADMIN"
}'
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $DATAIKU_API_KEY" \
-d "$PAYLOAD" \
"$DATAIKU_URL$ENDPOINT"
But this is throwing below error. Need help to fix it ASAP.
<html>
<head><title>405 Not Allowed</title></head>
<body>
<center><h1>405 Not Allowed</h1></center>
<hr><center>nginx</center>
</body>
</html>
Operating system used: Redhat
Answers
-
Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,211 Dataiker
Hi,
We recommend using Python API directly :
https://community.dataiku.com/t5/Using-Dataiku/How-to-create-a-Dataiku-user-using-python-script/m-p/21337/highlight/true#M8360
In your request the -> Authorization: Bearer is incorrect.As shown in the example here:
https://doc.dataiku.com/dss/api/12/rest/
curl --user <USER_API_KEY>: -H "Content-Type: application/json" -X GET http://mymachine:port/public/api/projects/
You need to pass :
Authorization: Basic <base64_encoded_api_key>'
if you are using curl you can --user with user_api_key as explained in the docs.
Let me know if this helps! -
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 1,876 Neuron
That's not Python but a Bash script. I concur with Alex, you will be much better off using the Python API than via curl which won't handle errors properly.