2 Replies Latest reply on Jun 1, 2017 10:45 AM by ryanrutan

    Adding users to security group using REST API giving a 401 error

    mayuriumranikar

      Hello,

       

      I am trying to add users to the security group using Jive REST API v3.14 → SecurityGroup entity  and my post looks like https://*****/api/core/v3/securityGroups/1004/members

      It is a application/json where I pass in the URI of the member(s) I want to add -> {["https://rsa-preview2.jiveon.com/api/core/v3/people/2058"]}

      I also know that the account I'm using has the admin rights. But I still get : "Jive returned a 401 status code. The operation is not authorized for some reason."

      Btw, GET security groups works.

       

      Can someone please help me in resolving this issue? I also referred to want to add members to a securitygroup with API but error 500  but it doesn't apply to me.

       

      Thanks in advance for the help!

      Mayuri

        • Re: Adding users to security group using REST API giving a 401 error
          Raj Vachhani

          I had hard time to get it work. I was synchronizing the Active directory groups members to Jive. Try below function to generate the JSON. It works for me.

           

                 private string ConstructPeopleURLs(List<string> jiveIds)
                  {
                     // string[] arrJiveIds = jiveIds.Split(',');
                      StringBuilder sb = new StringBuilder();

                      for (int i = 0; i < jiveIds.Count(); i++)
                      {
                          if (jiveIds.Count() == i + 1)
                              sb.AppendFormat("\"{0}{1}{2}\"", JiveAPIUrl, "people/", jiveIds[i]);
                          else
                              sb.AppendFormat("\"{0}{1}{2}\",", JiveAPIUrl, "people/", jiveIds[i]);
                      }

                      string val = "[" + sb.ToString() + "]";
                      return val;

                  }

           

           

          • Re: Adding users to security group using REST API giving a 401 error

            One thing, the payload is an array of strings, so do:

            ["xxxxxx","xxxxxx"]

            as the full payload...do not try to wrap it in a JSON structure.

             

            Status code 401 means unauthorized.  Make sure you are using a rightly scoped admin token and/or that the user you are using ... as marked as an admin of that security group and/or has the appropriate Admin permissions to perform that request.

             

            Hope that helps.

            1 person found this helpful