Survey banner
The Dataiku Community is moving to a new home! We are temporary in read only mode: LEARN MORE

Unable to create DSS users using shell script

mettuharish
Level 3
Unable to create DSS users using shell script

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

0 Kudos
2 Replies
AlexT
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/...
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!

 

0 Kudos
Turribeach

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. 

0 Kudos