Zendesk REST API tutorial - Listing the followers of a KB section Follow

Comments

7 comments

  • Avatar
    Valeri

    Really helpful article. I've written the code with Python, but what I need to do next to integrate my API? Thank you!

  • Avatar
    Mike Taylor

    Charles, your excellent article helped me finally create a list of followers to a section of articles. (I cannot believe zendesk doesn't offer this as basic functionality 101, listing section followers, but it is what it is.) 


    I am not a coder but was able to follow your instructions above and get the python file to work. It has done so for several weeks, then today it has run but listed only 3 names, where I expected 20+. 


    I haven't changed anything about the .py file since authoring it, so wonder what could cause this reduction/error. (It is not 20 people unfollowing as I have confirmation they received a recent article posting).


    Thanks for your help.


    Michael

  • Avatar
    Charles Nadeau

    Hi Mike,


    Hard to tell what's going on. I tested the script again to check for any change in the JSON attribute names since I wrote it, but everything still seems to be working for me.


    Is there something in common with the users who are actually listed? For example, are they all agents?

  • Avatar
    Mike Taylor

    Charles,


    The three people being listed are customers who follow a section we have called AO Enhancements (AO is our software). The full list of 20+ that was being reported did include three agents.


    I do need to get this resolved quickly, as we are adding new customers and I need to be able to track software enhancement followers. Should I submit a help request, or can I send you my .py file to run and diagnose?


    Thanks for your support.


    Michael

  • Avatar
    Charles Nadeau

    Hi Mike,


    Can you send me your Python file with the credentials removed? Also, can you send me the Help Center settings for the section in question? Click the section name, then click Edit. I'm particularly interested in the Who Can View? setting.


    Thanks.


     

  • Avatar
    Charles Nadeau

    Hi Mike,


    I think I found the problem. The last 2 lines of your script to print the results are:


    for user in data['users']:
    
    print(user['name'])

    The first line of the snippet should be:


    for user in users:
    
    print(user['name'])

    The users variable is where you cumulatively save the user records if the API returns multiple pages of results.


    The data['users'] variable is different. It contains only the page of results returned by the API. For the subscribers API, each page consists of a maximum of 30 records. If more than 30 people subscribe to a section, then the API returns a second page of results with only the additional people. The contents of data['users'] consists of only those records. And so on when you reach 60 +1 subscribers.


    Your script worked when you had less than 30 subscribers. As soon as you had over 30 subscribers, the value of data['users'] at the end of the script only contained the second page of results -- I think 3 users in in your case. However, all 33 users were stored in the users variable.


    Hope this makes sense.


    Charles


     

  • Avatar
    Mike Taylor

    Charles, sorry for the delay in responding, vacation. Your adjustment to the code worked perfectly. Thank You. Up and running again. 

Please sign in to leave a comment.

Powered by Zendesk