VMware Workspace ONE Community
jankre
Contributor
Contributor

Rest Api - How to create a new smart group?

I'm trying to create a new Smart Group using the rest api.
I do a POST to this uri ..../api/mdm/smartgroups
with this body
{ ' Name' : ' My new smart group' , ' CriteriaType' : ' All' , ' ManagedByOrganizationGroupId' : ' 614' , ' OrganizationGroups' : [ { ' Id' : ' 614'  } ] } 
No matter what i try, I only get this error message back:
{ ' errorCode' : 6, ' message' : ' Parameter Type cannot be null or empty' , ' activityId' : ' 48775788-ff2f-4a43-90ed-b4b873291af1'  }

There is no parameter named ' Type'  in the documentation.
Any suggestions?

Labels (1)
0 Kudos
2 Replies
habit81
Enthusiast
Enthusiast

Hi Jan,

I've just tested in 1811 and it worked fine. Below is the PS code I used. Hope it helps.

$SmartGroup = @{}
$SmartGroup.Name = ' SOME_NAME'
$SmartGroup.ManagedByOrganizationGroupId = ' ORGANIZATIONGROUP_ID'
$SmartGroup.OrganizationGroups = @()
$SmartGroup.OrganizationGroups += @{' Id'  = ' ORGANIZATIONGROUP_ID' }
$JsonSmartGroup = $SmartGroup | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri ' https://AWTENANT/api/mdm/smartgroups'  -Headers $Header -Body $JsonSmartGroup
0 Kudos
jankre
Contributor
Contributor

Jakub H. - thanks for your reply.
I realized that I was using the wrong version header. Accept: application/json;version=2
Should be version 1.
0 Kudos