1 Reply Latest reply on Jan 20, 2016 3:19 PM by jbroman

    Security Group REST API

    lenny.blum

      I have an HTTP call that I am trying to change into a python REST call.

       

      The HTTP call is:

      curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST --data '["https://xxx.jiveon.com/api/core/v3/people/4690"]' https://xxx.jiveon.com/api/core/v3/securityGroups/1009/members
      

       

      Which works.

       

      The Python code is:

       

      import requests, csv, json, base64
      
      securityGroupID = 1009
      personID =  4690
      memberList = []
      
      uri = "/api/core/v3/securityGroups/{}/members".format(securityGroupID)
      base_url = "https://xxx.jiveon.com"
      url = base_url + uri
      
      print (url)
      user = "xxx"
      password = "yyyy"
      
      auth = "Basic " + base64.encodestring('%s:%s' % (user, password)).replace("\n","");
      
      headers = { "Content-Type": "application/json", "Authorization": auth }
      
      
      data = json.dumps(
           {
            "uri" : "https://xxx/api/core/v3/people/{}".format(personID)
        })
      
      try:
          req = requests.post(url, data=data, headers=headers )
          print "Member Created"
      except:
          print req.text
      

       

      which does not work.

      I get the following error:

      reply: 'HTTP/1.1 500 Internal Server Error\r\n'