Update user with REST API

232 views Asked by At

One of our users has status = Inactive in Admin setting. I tried to set it to active using rest api and the documentation but seems like api is not changing status.

sources:

databricks documentation

youtube tutorial

I tested api and I can list users so api settings are ok.

api request:

import requests
import json

run_update = {
  "schemas": [ "urn:ietf:params:scim:api:messages:2.0:PatchOp" ],
  "Operations": [
    {
      "op": "replace",
      "path": "active",
      "value": [
        {
          "value": "true"
        }
      ]
    }
  ]
}
headers = {"Authorization": "Bearer token"}
create_response = requests.patch(host + '/api/2.0/preview/scim/v2/Users/userid', data=json.dumps(run_update), headers=headers)

create_response.status_code = 200

Any idea how to fix this code or basically how to set users status = active so he can work in databricks? I tried also to remove user from the group and add him again, but status was still inactive.

1

There are 1 answers

3
Zollnerd On

Complete guess - it looks like the value for the active attribute is being sent as a string? Try changing it to Boolean (i.e.: no quotes - so "value": true ).