5 Replies Latest reply on Feb 5, 2015 12:03 PM by david.bastedo

    Cannot find discussion post when using REST api

    philn

      Hi,

      I have been trying somewhat unsuccessfully to find my test discussion posts to our cloud instance.

       

      I have been using a non federated test account with basic authentication, as our instance is set up to use SSO (SAML). I cannot see any posts in that (test) accounts content area. I have tried searching the whole of our instance with no luck. I do not receive any errors trying to connect , so I can only assume that I am missing something from my JSON request. I have also used Chrome's REST web service client to test and receive the same results.

       

      Below I have included both the request and response I receive:

       

      POST https://<jiveURL>/contents/

      Accept: application/json

      Content-Type: application/json

      Authorization: Basic am9lLmJsb2dnc0B2b2NhbGluay5jb206S2VpdGgxMjM=

      {

      "content":

      { "type": "text/html", "text": "

      Some interesting text to discuss today....

      " },

      "subject": "New Discussion",

      "type": "discussion",

      "parent": "https://<jiveUrl>/groups/recognition-awards/content",

      "visibility": "all"

      }

       

      [RESPONSE]

      200, OK Date: Wed, 04 Feb 2015 14:22:03 GMT

      Content-Encoding: gzip

      Vary: Accept-Encoding P3P: CP="CAO PSA OUR"

      Server: Apache

      X-Frame-Options:SAMEORIGIN

      X-Jive-Request-Id: 30bcfe30-ac79-11e4-8516-005056b33d1f

      Content-Language: en-GB

      Cache-Control: no-store, no-cache, must-revalidate, private, max-age=0 Transfer-Encoding: chunked Connection: keep-alive, Transfer-Encoding

      X-JSL: D=64364 t=1423059723666738

      Content-Type: text/html;charset=UTF-8

      X-Jive-Flow-Id: 30bcfe31-ac79-11e4-8516-005056b33d1f

      Expires: Wed, 04 Feb 2015 14:22:03 GMT

       

      Time taken (in milliseconds): 279

       

      Any suggestion of where to look would be most welcome.

       

      Thanks,

       

      Phil

        • Re: Cannot find discussion post when using REST api

          Hi philn -

           

          The "parent" object you specify in your JSON body has to point to the "places" API endpoint for a place, and not the actual URL that an end user would go to. For example, instead of https://<jiveUrl>/groups/recognition-awards/content you will want to use an API endpoint like https://<jiveurl>/api/core/v3/places/1102.  You'll need to use the API to find the correct place ID for your group.

           

          It also looks like the "visibility" is not a valid field to set when creating a new discussion.  Here is what worked for me:

           

          {

          "content":

          { "type": "text/html", "text": "Some interesting text to discuss today...." },

          "subject": "New Discussion",

          "type": "discussion",

          "parent": "<jiveurl>/api/core/v3/places/1102"

          }

           

          When you run this API call you should get a a 201 response code, which is the response code for "Created".  The body of this response will be the JSON for the new piece of content, which should make it easy to find the new piece of content.

           

          When I ran the example code you have created I get a 400 error with the following returned text:

          {

            "error" : {

              "code" : "placeInvalidURI",

              "message" : "A parent was specified for this content",

              "status" : 400

            }

          }

           

          I am surprised to see that you're getting a 200 response.  I'm not sure why that would be.

           

          Let me know if this helps.

            • Re: Cannot find discussion post when using REST api
              philn

              Thanks David for replying. When i'm back in the office I will try what you have suggested. I assumed it was my JSON that was incorrect but wasn't sure where exactly the problem was.

              • Re: Cannot find discussion post when using REST api
                philn

                Hi David,

                 

                I have tried what you suggested and I am still not able to say any posts.

                 

                I have got a bit further in that the reason I was seeing http status code 200 was due to the fact that my call was getting redirected to the login page. Our instance is set up to use SSO (SAML) but I was under the impression that if I used a non federated account set up within our instance and basic authentication I could still access our instance. Is that correct?

                • Re: Cannot find discussion post when using REST api
                  philn

                  Hi David,

                   

                  I finally got it to work.

                   

                  After a bit of trial and error I amended the URL I was posting to - <jiveUrl>/api/core/v3/places/{placeid}/contents and added that same path to my parent property in my JSON object and my post appeared where I expected it to, so thanks for your help.

                   

                  One last question though what is the correct format of the author property as I would like to dynamically add in those credentials in from a separate application?

                   

                  Thanks again,

                   

                  Phil