cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Adding Member to group using account databricks rest api

pragarwal
New Contributor II

Hi All,

I want to add a member to a group in databricks account level using rest api (https://docs.databricks.com/api/azure/account/accountgroups/patch) as mentioned in this link I could able to authenticate but not able to add member while using below body. Could please someone guide what i missed to add in body?

{"schemas": [
"urn:ietf:params:scim:api:messages:2.0:PatchOp"
],
"Operations":[
{
"op": "add",
"path": "/members",
"value": "xyz@abcdcomapny.com"
}
]
}

6 REPLIES 6

pragarwal
New Contributor II

Hi @Retired_mod 

I have tried suggest body also but still member is not added to group. is there any other method that i can use add member to the group at account level

Thanks,

Phani.

larsr
New Contributor II

@Retired_mod  I am having the same issue as @pragarwal : after sending the api request and getting success code 200 the member is not added to the admin group.

shingot
New Contributor II

 

I am working on workspace-local group APIs on Azure Databricks though what @Retired_mod suggested did not work to me too. I checked the payload sent from Databricks workspace frontend and the following worked to me. Has API signature been changed but document hasn't been updated?

 

 

 

 

{
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:PatchOp"
  ],
  "Operations": [
    {
      "op": "add",
      "value": {
        "members": [
          {
            "value": "0000000000000000 (replace this with your Databricks USER ID)"
          }
        ]
      }
    }
  ]
}

 

 

Edit:

I am using PATCH `/api/2.0/preview/scim/v2/Groups/{id}` API. I found another doc which looks like v2.1 API reference and the signature looks quite similar to what I used.

Account SCIM 2.1 Documentation (databricks.com)

 

 

shingot
New Contributor II

Looks like value should be an array. This worked to me to add three users to a group. Replace xxx/yyy/zzz with account ID.

 

{
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:PatchOp"
  ],
  "Operations": [
    {
      "path": "members",
      "op": "add",
      "value": [
        {
          "value": "xxx"
        },
        {
          "value": "yyy"
        },
        {
          "value": "zzz"
        }
      ]
    }
  ]
}

 

 On the other hand, remove operation seems a bit different format. Add remove operation for each entry to remove. Here is an example to remove three users with ID xxx, yyy and zzz from a group.

 

{
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:PatchOp"
  ],
  "Operations": [
    {
      "op": "remove",
      "path": "members[value eq \"xxx\"]"
    },
    {
      "op": "remove",
      "path": "members[value eq \"yyy\"]"
    },
    {
      "op": "remove",
      "path": "members[value eq \"zzz\"]"
    }
  ]
}

 

 

Nikos
New Contributor II

Does the above work? I still can't quite figure it out. Any help would be much appreciated.

I know authentication is not an issue as I can use a lot of the other endpoints. I just can't figure out the correct body syntax to add a member to a group.

url= https://accounts.azuredatabricks.net/api/2.0/accounts/<account_id>/scim/v2/Groups/<group_id>

data= {
  'schemas': [
    'urn:ietf:params:scim:api:messages:2.0:PatchOp'
  ],
  'Operations': [
  {
    'op': 'add',
    'path': '/members',
    'value': {
      'value': '<user>@<domain>.com'
    }
  }
  ]
}

header={'Content-Type': 'Authorization': 'Bearer <token>'}

 

My code is

requests.patch(url=url, data=data, headers=header)
 
 
Error:
{
'schemas': [
'urn:ietf:params:scim:api:messages:2.0:Error'
],
'scimType': "Invalid JSON provided in request body. PATCH\nUnrecognized token 'schemas': was expecting ('true', 'false' or 'null')\n at [Source: schemas=urn%3Aietf%3Aparams%3Ascim%3Aapi%3Amessages%3A2.0%3APatchOp&Operations=op&Operations=path&Operations=value; line: 1, column: 8]",
'detail': 'Request is unparsable, syntactically incorrect, or violates schema.',
'status': '400'
}

mauri_murillo
New Contributor II

This payload worked for me:

URL: https://{databricks_instance}/api/2.0/account/scim/v2/Groups/{group_id}

PATCH with this payload

{
"schemas": ["urn:ietf:params:scim:api:messages:2.0:PatchOp"],
  "Operations": [
{
"op": "add", 
"value": {
"members": [
{"value": "{user_id}"}
]
}
}
 ]
}

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group