3 Replies Latest reply on Dec 9, 2016 2:28 PM by jgoldhammer

    osapi.jive.core.get - return the reponse as Object {status: 204}

    yogesh.r

      Hi Rashed Talukder Pawan Shah Scott A Johnson

      I working on the requirement to get all the group members of selected place in places request picker . I am passing the place member url to get the all the members.

      When separately browse the url it returns correct result. if we  use the osapi jive core get it return the blow message. 

      Issue  : osapi.jive.core.get - return the reponse as Object {status: 204}

       

      function searchgroupmemeber(){

       

        osapi.jive.corev3.places.requestPicker({

        type:"group",

            success  : function(data) {

        var urlGroupMembers=data.resources.members.ref;

        getAllGroupmembers(urlGroupMembers);

         } 

           });

        }

       

      function getAllGroupmembers(memeberUrl)

        {

        osapi.jive.core.get({

      v:"v3",

        href:memeberUrl    ///api/core/v3/members/places/550349

        }).execute(function(response ) {

        console.log(response); //Object {status: 204}

        })

        }

       

      Thanks

      Yogesh

        • Re: osapi.jive.core.get - return the reponse as Object {status: 204}

          The response should be a JSON object. If you're wanting to view the entire it in your DOM's stdout console window, you can turn the JSON object into a string: console.log(JSON.stringify(response));

            • Re: osapi.jive.core.get - return the reponse as Object {status: 204}
              yogesh.r

              After converting the object into Json.stirngify it return the the below response.

              {"status":204}

               

              When make use of the ajax  i'm able to get the result of the api data. 

              I am trying to send the direct message to selected group member urls.  the sent message inbox always with passed username.

              how to pass the logged user credential to ajax call.

               

              function searchgroupmemeber(){

               

                osapi.jive.corev3.places.requestPicker({

                type:"group",

                    success  : function(data) {

                var urlGroupMembers=data.resources.members.ref;

                getAllGroupmembers(urlGroupMembers);

                 }

                   });

                }

              var groupmemeberurls=[];

              function getAllGroupmembers(memeberUrl)

                {

                jQuery.ajax({

                          type: "GET",

                          contentType: "application/json",

                          headers: {

                              'Authorization': "Basic " + btoa("username" + ":" + "passowrd")

                          },

                          url: memeberUrl,

                          async: false,

                          complete: function(data) {

                              _data = JSON.parse(data.responseText.replace(/throw.*;/, "").trim());

                              console.log(_data);

                              if (_data.list.length > 0) {

                                  jQuery.each(_data.list, function(index) {

                                     groupmemeberurls.push(_data.list[index].person.resources.self.ref); //pushing the all the member url to array

                                  });

                                 

                              }

                          }

               

                      });

               

              function JiveInbox(groupmemeberurls)

                {

                var subject = "The subject";

                      var body = "Content of the direct message ";

                       var jsonData = {

                          "content": {

                              "type": "text/html",

                              "text": body

                          },

                          "subject": subject,

                          "type": "dm",

                "participants" : groupmemeberurls

                      };

               

                    jQuery.ajax({

                          type: "post",

                          contentType: "application/json; charset=utf-8",

                          'Accept': 'application/json',

                          url: '/api/core/v3/dms',

                          async: false,

                          data: JSON.stringify(jsonData),

                          dataType: "text",

                          complete: function(data) {

                              _data = JSON.parse(data.responseText);

                          }

                      });

               

              Thanks

              Yogesh