Intel vPro® Platform
Intel Manageability Forum for Intel® EMA, AMT, SCS & Manageability Commander
2834 Discussions

RestAPI: Add userGroup members not working

Jools86
New Contributor II
1,243 Views

Using the following POST method via PowerShell:

https://localhost/api/v5/userGroupMemberships/{userGroupId}/addMembers

 

I set the body as 

 

$UPN=@()
$UPN+="Julian.Loveday@mydomain.com"

#// Add to User Group
$Body = @{
'UserName'=$UPN
}
$JSON=$Body | ConvertTo-Json
$UserGroup=Invoke-RestMethod "https://ema.mydomain.com/api/latest/userGroupMemberships/$EMAUserGroupId/addMembers" -Headers $headers -Body $JSON -Method Post

 

however I see this error every time:

Jools86_0-1675255813244.png

 

I tried changing to

$UserGroup=Invoke-RestMethod "https://ema.mlp.com/api/latest/userGroupMemberships/$($EMAUserGroupId)/addMembers" -Headers $headers -Body $JSON -Method Post

 

and even changing to

$UserGroup=Invoke-RestMethod "https://ema.mlp.com/api/latest/userGroupMemberships/1/addMembers" -Headers $headers -Body $JSON -Method Post

 

Could you either:

a) Confirm there is a BUG in the RestAPI for adding members

or b) Send me an example if I am getting the syntax wrong.

 

As an FYI, token generates fine (code to generate headers below) - and I can run most other RestAPI queries using the below, its this specific one (https://localhost/api/v5/userGroupMemberships/{userGroupId}/addMembers) that is broken.

 

#// Generate token to be passed for authorization with each RestAPI request
$Token=Invoke-RestMethod "https://mydomain.mlp.com/api/latest/accessTokens/getUsingWindowsCredentials" -Credential $Cred

#// Generate header including token for each API request
$headers = @{
'authorization' = "bearer $($Token.access_token)"
}

 

0 Kudos
4 Replies
Victor_G_Intel
Employee
1,035 Views

Hello Jools86,

 

Thank you for posting on the Intel® communities.

 

Please let me review this information internally, and kindly wait for an update.

 

Once we have more information to share, we will post it on this thread.

 

Regards,


Victor G.

Intel Technical Support Technician  


0 Kudos
Victor_G_Intel
Employee
979 Views

Hello Jools86,


Thank you so much for your patience.


After analyzing your request, we have come to the conclusion that this is not a bug, but a syntax issue. It looks like you are attempting to use an array $UPN=@()

 

Swagger syntax calls for the UPN to be a call for a "string"... "UserName": "string"

 

If you remove the array and turn it into a string it should work fine:


#Example

$UPN="Julian.Loveday@mydomain.com"

#// Add to User Group

$Body = @{

'UserName'=$UPN

}

$JSON=$Body | ConvertTo-Json

Write-Host $JSON

 

the output will look like as opposed to nothing in an array

{

  "UserName": "Julian.Loveday@mydomain.com"


Best regards,


Victor G.

Intel Technical Support Technician  


0 Kudos
Victor_G_Intel
Employee
938 Views

Hello Jools86,


Were you able to check the previous post?  


Please let me know if you need further assistance.  


Best regards,

 

Victor G. 

Intel Technical Support Technician 


0 Kudos
Victor_G_Intel
Employee
901 Views

Hello Jools86,


We have not heard back from you.


If you need any additional information, please submit a new question as this thread will no longer be monitored.


Regards,


Victor G.

Intel Technical Support Technician


0 Kudos
Reply