Most efficient way to add a user to a group?

  • Is there a more efficient way to add a user to a group, than issuing a PATCH request passing the entire updated list of user shortIds to /odata/usersGroups?

    Current code (using got package for HTTP calls):

    const usersGroupUpdateUrl = `${jsReportSettings.url}/odata/usersGroups(${usersGroupId})`;
    // Send a PATCH request with full list of users
    const usersGroupUpdateResponse = await got.patch(usersGroupUpdateUrl, {
      json: {
        users: [...usersGroupUsers, { shortid: newUser.shortid }],

    Can I POST just the new user payload { shortid: newUser.shortid } to that endpoint or something instead perhaps?

    What I have works fine, but just means I need to query for the current list of users first, then update the array and then issue the PATCH request. Would be nicer to just be able to send the new user payload and have the backend handle all that.

  • I am afraid there is no an extra route and you need to set the whole list.

Log in to reply

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.