Skip to main content
Question

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

  • January 14, 2016
  • 3 replies
  • 9 views

Forum|alt.badge.img+4

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.

3 replies

stevewood
Forum|alt.badge.img+38
  • Hall of Fame
  • January 14, 2016

@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>.


Forum|alt.badge.img+4
  • Author
  • New Contributor
  • January 14, 2016

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


Forum|alt.badge.img+4
  • Author
  • New Contributor
  • January 14, 2016

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