user create api error

I am currently working on a project in which I need to create user programatically through API. The endpoint I am using:api/rest/2.0/users/create. I am getting error while running above endpoint in postman.Details in below section. header: X-Requested-By:ThoughtSpot Content-Type:application/x-www-form-urlencoded Accept:application/json Authorization: Bearer QxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxhWnow request body:{ "name": "name6 tte", "display_name": "test test", "email": "[email protected]", "account_type": "LOCAL_USER", "account_status": "ACTIVE", "visibility": "SHARABLE", "notify_on_share": true, "show_onboarding_experience": true, "onboarding_experience_completed": false, "group_identifiers": [ "1a4xxxxxxxxxxxxxxxxx6f259" ] } Error: { "error": { "message": { "debug": "Variable "$name" of required type "String!" was not provided." } } }
9 Replies
ashish
ashish13mo ago
The content-type needs to be "application/json". Have you tried using the API playground within the dev portal of your instance ? That should create the request in the correct format automatically for you.
https://<ts-instance>/#/develop/api/rest/playgroundV2_0?apiResourceId=http%2Fapi-endpoints%2Fusers%2Fcreate-user
https://<ts-instance>/#/develop/api/rest/playgroundV2_0?apiResourceId=http%2Fapi-endpoints%2Fusers%2Fcreate-user
Ansh Jaiswal
Ansh JaiswalOP13mo ago
No description
No description
No description
bill_da_golfer
bill_da_golfer13mo ago
I'm not sure about the error message, but you should also need a password. I'm noticing it's not listed as "required", but I believe it is for a local user (else how do they log in).
Also, as @ashish indicated, you do need to make sure the accept/content-type is application/json in the header if it's not.
Ansh Jaiswal
Ansh JaiswalOP13mo ago
Content type is json only I'll try adding password If error persists I'll reach out here again
Sandeep
Sandeep13mo ago
Password field is marked as optional. Reason being, In case of LOCAL_USER password is required and in case of SAML_USER it is optional. Depending on the user_type selected, the API should throw 400 Response code stating password is required field here. Looks like the response code is correct but the response message is coming as blank which is creating confusion here. We will be fixing the response message in the upcoming release but if we need to back port the fix would you mind logging a support ticket to take it forward.
Ansh Jaiswal
Ansh JaiswalOP13mo ago
Sure,just guide me what I have to do
Sandeep
Sandeep12mo ago
Have you tried adding the password field as @bill_da_golfer suggested and tried the API?
Sandeep
Sandeep12mo ago
Sample request and response
No description
Ansh Jaiswal
Ansh JaiswalOP12mo ago
Yes it's working,thankyou.

Did you find this page helpful?