2 Replies Latest reply on Apr 6, 2016 7:18 PM by marxav

    How to use contentImages in a discussion API?

    marxav

      I can successfully upload an image with Jive API v3 (e.g. iris.png).

      I can also successfully create a new discussion (e.g. discussion "Test" with "blabla" text)

      However, I can not succeed into creating a new discussion that integrates the uploaded image. It looks to me as if the contentImages is not taken into account ; indeed the discussion is nevertheless created with a "blabla" text, but the image is not contained in the returned discussion. How could I solve that?

       

      # Example of code

       

          image= {

           "id" : "188118",

            "contentType" : "image/png",

            "name" : "iris.png",

            "ref" : "https://foo.com/plazza/api/v3/images/188199?a=8375989218914",

            "size" : 94622,

            "width" : 2400,

            "height" : 1800,

            "type" : "image"

           }

       

              headers = {"Content-Type": "application/json"} 

              data = json.dumps({ 

                  "type":"discussion",

                  "subject":"Test", 

                  "parent":"https://foo.com/plazza/api/v3/places/123456", 

                  "content" : {

                      "type" : "text/html",

                      "text" : "<p>blabla</p>"

                  },

                  "contentImages" : [ image ]

              })

       

              url = "https://foo.com/plazza/api/v3/contents"

              r = requests.post(url, data=data, headers=headers, auth=(user, password)) 

              print("r.status=",r2.status_code)  

              print("r.text=",r2.text)

        • Re: How to use contentImages in a discussion API?

          You did everything just fine, but your content body has no reference of the image. (e.g.: "text" : "blabla \<img src=src=\"/api/core/v3/images/188199\" /\>"

           

           

          Another thing, the "a" parameter needs to be removed from your image url in order for the DB to convert it to a permanent image once it's associated with a piece of content.

           

          The other thing...I noticed your path isn't /api/core/v3/

            • Re: How to use contentImages in a discussion API?
              marxav

              Having read your solution, I now feel stupid realizing my HTML indeed needs to include the <img> tag.

              Huge thanks, it solved the problem

               

              The other thing...I noticed your path isn't /api/core/v3/

              I had cleaned my real Jive URIs hoping for quicker readibility when looking at the pseudo code, which was not a good idea. Yes, you're correct, I indeed have /api/core/v3/ in my real code.