JSS Rest API - Add users to usergroup returns HTTP 400 (Bad Request)

actademo
New Contributor

Hello,

I am trying to add users to a usergroup using the JSS Rest API.
Reading the documentations the request should look like this:

<user_group>
  <user_additions>
    <user>
      <id>1</id>
    </user>
  </user_additions>
</user_group>

However, I get a HTTP 400 (Bad Request) in return from the server.
Is there something wrong in the XML?

See the image below for Update note.
721d74c57fca4ccdade5496932c5088d

3 REPLIES 3

stevewood
Honored Contributor II
Honored Contributor II

@actademo try using this XML data format:

apiData="<user_group><user_additions><user><id>{id}</id></user></user_additions></user_group>"

Where you replace {id} with the ID number or a variable representing the ID. I just tested on my JSS and that will add a user to a User Group. I know that the XML lists it as a plural (<user_groups>), but I found that it is not in fact plural. Same with <user> instead of <users>.

actademo
New Contributor

@stevewood I used your XML (wich is the same as my XML?) and still get the 400 Bad request..

actademo
New Contributor

@stevewood Found the mistake... I was consuming the UpdateUser address instead of the UserGroup address... stupid mistake