1 Reply Latest reply on Jan 28, 2014 4:54 PM by kevin@puppetlabs.com

    Help posting content with JIVE api and python

    kevin@puppetlabs.com

      I want to documents to Jive through the API. A python script using the method below gives me a 200 status and returns what appears to be the full json of everything under /contents, but it doesn't seem to be creating anything. I'm having trouble finding any consistent source of documentation to address this. As Jive seems to think everything is working well and isn't returning errors, I'm not sure how else to approach this. I'm relatively ignorant about all elements involved, so any wisdom would be much appreciated!

       

      def post():
          uri = "/api/core/v3/contents"
          url = base_url + uri
          
          headers = { "Content-Type": "application/json", "Authorization": auth }
      
          data = json.dumps(
               { "content": {
                     "type": "text/html",
                     "text": "<p>Test/p>"
                     },
                 "subject": "API Test",
                 "type": "document",
               })
      
          req = urllib2.Request(url, data, headers)
          
          print req.get_method()
          print req.get_data()
      
          try: 
              result = urllib2.urlopen(req)
              print result.getcode()
              output = result.read()
          except urllib2.HTTPError, e:
              print e.code
              print e.read()