1 Reply Latest reply on Oct 8, 2014 6:47 AM by thales

    Using Rest API to get the maximum number of group invites

    thales

      I am comparing the differences in the API versions. It appears that v2 and v3 have different max count values. v2 has a max of 1000 and v3 has a max of 100.

       

      uri = "/api/core/v2/invites?groupID={}&limit={}".format(group, maxReturn) #max is 1000
      
      uri = "/api/core/v3/invites/places/{}?count={}".format(placeID,maxReturn) #max is 100
      

       

      As I am using the api within Python, I assume that I need to create a loop that modifies the startIndex based upon the number of records I have already returned.

       

      It also seem that if there is truly a max count for returning these items, then it should be properly documented in the help - Jive REST Rest API v3.8 → Invite service

       

      API v2 also provides better feedback in the json response.

       

      {u'message': u'Limit exceeded; maximum limit is 1000', u'code': 4039} #v2 error message
      
      {u'error': {u'status': 400, u'message': u'Invalid count 500', u'code': u'genericInvalidCount'}} #v3 error message
      
        • Re: Using Rest API to get the maximum number of group invites
          thales

          I was able to accomplish getting all of the invites using a While Loop.

           

          import json, base64, requests, time
          
          placeID = "1000"
          maxReturn = 100 #Max number of invites to process per loop. 100 is max for API v3.
          totalInvites = 100 #Number of invites in group. Loops through invites based upon maxReturn value until all invites are retrieved.
          start = 0 #startIndex
          
          while (start < totalInvites): 
              #Group members uri
              uri = "/api/core/v3/invites/places/{}?count={}&startIndex={}".format(placeID,maxReturn,start)
              base_url = "https://community.com"
              url = base_url + uri
              start += maxReturn