5 Replies Latest reply on Apr 18, 2016 1:23 PM by Scott A Johnson

    jive get people api by date

    sbollap1

      I am trying to use a regular expression as shown below, just wanted to know if this should work, basically want to get the people for certain published dates, but its not working, any clues would be appreciated

       

      var request = osapi.jive.corev3.people.get({count: 2, "fields": "@all", published: "2013-12.-*" });
      ...
      request.execute(function(response) {
      

      or is there a way to use something like this?

       

      var params = {
       count: 2,
       "fields": "@all",
       filter: "2013-12.*"    <------ not sure if this or the below line would work
       href: /filter?published=2013-12.*  
      }
      
      requrequest.get(params).execute(function (response) {...});
      
        • Re: jive get people api by date
          Scott A Johnson

          Hi Shan,

           

          I'm not sure that a regular expression is valid in this filter.

           

          The examples from the documentation show this filter accepting one or two dates.

           

          One date indicates everything since that date, two dates indicates everything between those two dates. I have found no documentation that covers a regular expression example.

           

          Scott

          • Re: jive get people api by date
            sbollap1

            Is there a filter example within the json object ? like this

             

            var x = {  count: 10,

                           filter:   ?????? what goes here for the value, and can the key be filter ?

                        }

             

            I tried this but getting an error

            var request = osapi.jive.corev3.people.search({count: 2, "fields": "@all", filter: '=published(2013-12-05T08:08:55.674+0000)' });
            
            and 
            
            
            {
            count: 2,
            filter: published(2013-12-05T08:08:55.674%2B0000)
            }
            
              • Re: jive get people api by date
                Scott A Johnson

                I tried something similar to what you did.

                 

                osapi.jive.corev3.people.get({filter: 'published(2016-01-31T00:00:00.000%2B0000)'}).execute( function(results) {
                  console.log(results);
                });
                

                 

                I got an error which indicated a bad filter value was passed in.

                 

                [
                    {
                        "id": "jive.core.get", 
                        "result": {
                            "error": {
                                "code": "filterInvalid", 
                                "message": "Invalid filter expression filter(published(2016-01-31T00:00:00.000%2B0000))"
                            }, 
                            "status": 400
                        }
                    }
                ]
                

                 

                Hmm, why is that invalid?

                 

                Well, lets look at the request payload:

                 

                [
                    {
                        "id": "jive.core.get", 
                        "method": "jive.core.get", 
                        "params": {
                            "groupId": "@self", 
                            "href": "/people?filter=filter(published(2016-01-31T00%3A00%3A00.000%252B0000))", 
                            "userId": "@viewer", 
                            "v": "v3"
                        }
                    }
                ]
                

                 

                Oh, its translating that json filter into "?filter=filter(published(...))", it should be "?filter=published(...).

                 

                Lets make a change to our code:

                 

                osapi.jive.corev3.people.get({published: '2016-01-31T00:00:00.000%2B0000'}).execute( function(results) {
                  console.log(results);
                });
                

                 

                Oh, no! Another error! This time it looks like this.

                 

                [
                    {
                        "id": "jive.core.get", 
                        "result": {
                            "error": {
                                "code": "genericInvalidDate", 
                                "message": "Invalid date format 2016-01-31T00:00:00.000%2B0000"
                            }, 
                            "status": 400
                        }
                    }
                ]
                

                 

                Ok, invalid date format, lets again look at the request:

                 

                [
                    {
                        "id": "jive.core.get", 
                        "method": "jive.core.get", 
                        "params": {
                            "groupId": "@self", 
                            "href": "/people?filter=published(2016-01-31T00%3A00%3A00.000%252B0000)", 
                            "userId": "@viewer", 
                            "v": "v3"
                        }
                    }
                ]
                

                 

                Taking the url and passing it through a URL Decoder, it shows "/people?filter=published(2016-01-31T00:00:00.000%2B0000)". Oh, so it's still sorta encoded! "%2B" should be +.

                 

                Lets try one more round.

                 

                osapi.jive.corev3.people.get({published: '2016-01-31T00:00:00.000+0000'}).execute( function(results) {
                  console.log(results);
                });
                

                 

                This time we did it! Valid response looks like this:

                 

                [
                    {
                        "id": "jive.core.get", 
                        "result": {
                            "content": {
                                "itemsPerPage": 25, 
                                "links": {
                                    "next": "https://sandbox.jiveon.com/api/core/v3/people?sort=firstNameAsc&fields=%40summary&filter=published%282016-01-31T00%3A00%3A00.000%2B0000%29&origin=unknown&count=25&startIndex=25"
                                }, 
                                "list": [
                                ...
                                ], 
                                "startIndex": 0
                            }, 
                            "status": 200
                        }
                    }
                ]
                

                 

                Hope this helps.

                 

                Seems like this also indicates that we could pass a number of options into the get argument object (pretty much anything that is a valid filter for the people get service.

                 

                Scott

                2 people found this helpful
              • Re: jive get people api by date
                sbollap1

                thank you. Scott A Johnson can you please tell me how you are seeing the request payload. i am looking at the dev tools tab in the chrome and looked around in the network > headers/response tabs. also, the request you are making did you make them from a client of some sort, because i am every time packing the tile it using jive-sdk build add-on --apphosting="jive" and then uploading the extension.zip file to the community via addon's and viewing it. kind of pain.

                  • Re: jive get people api by date
                    Scott A Johnson

                    In Chrome dev tools, Network -> Headers, scroll all the way to the bottom, you'll see the Request Payload section.

                     

                    I created a simple app using jive-sdk create app. Then modified the sample code to include these calls when the "Invoke Popup" button is clicked. I didn't try it in a tile, but I dont see why it wouldnt work if you were using a custom view tile.

                     

                    Scott