3 Replies Latest reply on Nov 19, 2014 2:18 PM by ryanrutan

    getNextPage HTTP400 error

    wb9tpg

      I'm having difficulty getting pagination working for after an osapi.jive.corev3.people.get call.  Here's what I'm going and I could use some guidance

       

      1. call osapi.jive.corev3.people.get with the options -> it returns a request object
      2. request.execute(callback) which returns a response object
      3. then called response.getNextPage() I believe returns a new request object
      4. call execute on that request object and it give a 400 error.


      I could not find any examples of getNextPage() in any of the examples in the sdk.   The javascript api had a recursive example that looked to me like it should work this way. 

        • Re: getNextPage HTTP400 error

          Hi Gary!

           

          Here is an example of this. It actually get's all users within a Jive system. Adapt to your liking:

              this.addAllCommunityMembers = function () {
                  var memberRequest = osapi.jive.corev3.people.get({ "count": 100 });
          
                  processListByPage(memberRequest);
          
                  function processListByPage(request) {
          
          
                      //Execute the request to get a list
                      request.execute(function (response) {
                          if (response.error) {
                              var code = response.error.code;
                              var message = response.error.message;
                              // present the user with an appropriate error message
                          } else if (!response.list) {
                              alert("Error: response is not a list!");
                          } else {
                              //console.log(response);
                              for (var i = 0; i < response.list.length; i++) {
                                  console.log(response.list[i]);
          
                                   //if you need more details about the user, make another call to osapi.jive.corev3.people to get the person details
                                  //getJiveContent('user', response.list[i].id, "displayName,emails,name.givenName,name.familyName,name,resources.avatar", function (responseJive) {
                                 //console.log(responseJive);
                                 
                                // });
                               self.assignees.push(response.list[i]);
          
                           }
                     if (response.getNextPage) {
                                  //console.log("next page");
                                  var requestNextPage = response.getNextPage();
                                  processListByPage(requestNextPage);
                              }
                           
                          }
                      });
                  };
          
          
              }