Forum Discussion

bhupen's avatar
bhupen
Advisor
11 years ago
Solved

Is there a way to export more than 25 unique usernames in csv/txt

I want to export a list of unique usernames for any given thread identified.

Solution I had:
 I have managed it using REST API with this call:
 /restapi/vc/threads/id/23/participants/recent.
 
Concern:
 This solutino is only giving me 25 user in output where as there are many users in the thread.
 Can someone help me out for this please

Help will be appreciated.

 

Regards

  • bhupen's avatar
    bhupen
    11 years ago
    samudhraa Thank you very much. I resolved this using this:
    <#assign x=10>
    <#list 1..x as pageNum>
    <#list restadmin("/threads/id/5719/participants/recent/?page=${pageNum}&page_size=1000").users.user as user>
    <#if user.login??>
    ${user.login}
    </#if>
    </#list>
    </#list>

7 Replies

  • Hi bhupen ,

     

    I was just wondering if you have used paging in your rest call. The usual REST result is 25 items (nodes) per page.You can use page size and page numbner to page through your results. Here is an example .

     

    /restapi/vc/threads/recent?page=1&page_size=50

     

    page_size - specifies the number of items per page.

    page         - specifies the page number.

     

    So in this example , I am asking for 50 thread items per page.You can keep iterating the page number and get the total list .

    If you are using a custom component , then there is a separate components for pagination which might be of use to you.

     

    Hope that helps.

     

    Thanks,

    Sam

     

  • bhupen's avatar
    bhupen
    Advisor
    11 years ago

    Hi samudhraa  Thanks for your reply.

     

    your trick works for me at halfway:
    /restapi/vc/threads/recent?page=1&page_size=50

     

    Now I have one more concern, we can set only page_size =<1000. But In my case there is more than 1050 pages and also i can't make pagination for records because iam exporting the user in csv format. I am using edpoints and downloading it in csv format.

     

    Now Iam able to export 1000 user only but my thread contains more than 14000 user and 1050 pages.

     

    Help is appreciated.

     

    Regards

    Bhupen

     

     

  • bhupen's avatar
    bhupen
    Advisor
    11 years ago

    Hi,

    Now I got the solution for this, but its not complete yet. I can export the user using below REST API but the concern is I have to change the page number "page=1&page_size=1000" inside endpoints, so how can I change page number dynamically inside endpoints.

     

    <#list restadmin("/threads/id/${RequestParameters.id}/participants/recent/?page=1&page_size=1000")

     

    Regards

     

  • samudhraa's avatar
    samudhraa
    Expert
    11 years ago

    Hi bhupen 

     

    Here is one way to do it , though I am not sure how efficient it would be , because we would be making rest calls within a loop , which is usually not advisable.

     

    <#assign totalCount = 12000/>

    <#assign itemsPerPage = 1000 />
    <#assign noOfPages = (12000/itemsPerPage) />       or ( <#assign noOfPages = (12000/1000) />)
    <#list 1..noOfPages as pageNum>

    <#assign getUser = rest("/threads/id/${RequestParameters.id}/participants/recent/?page=${pageNum}&page_size=1000") />

    </#list>

     

     

    Hope that helps.

     

    Thanks ,

    Sam

  • bhupen's avatar
    bhupen
    Advisor
    11 years ago
    samudhraa
    Thanks again for help. This is not showing me anything now. Neither error neither output. Now I can see only .csv is blank without any result. If this is not possible so can you suggest me how can I implement restcall outside loop.
    My concern is only to export users in csv. I have more then 15000 users and 1200 pages.
    Help is appreciated
  • samudhraa's avatar
    samudhraa
    Expert
    11 years ago

    Hi bhupen ,

    That was a snippet of code outlining the logic. You are supposed to loop through the api variable. The below is a working one , though I have changed the REST call. 

    <#assign totalCount = 12000/>
    <#assign itemsPerPage = 1000 />
    <#assign noOfPages = (12000/itemsPerPage) />

    <#list 1..noOfPages as pageNum>
    <#assign getUser = rest("/threads/recent?page=${pageNum}&page_size=10").threads />
    <#list getUser.thread as thread>
    ${pageNum} ${thread.@href} ${thread_index}
    <br/>
    </#list>
    </#list>

     

    Again , I would not advise that this is the efficient way to do it. I will let you know if I come up with a better way to do it. You could always contact Lithium support and get their idea on this.

     

    Thanks,

    Sam

  • bhupen's avatar
    bhupen
    Advisor
    11 years ago
    samudhraa Thank you very much. I resolved this using this:
    <#assign x=10>
    <#list 1..x as pageNum>
    <#list restadmin("/threads/id/5719/participants/recent/?page=${pageNum}&page_size=1000").users.user as user>
    <#if user.login??>
    ${user.login}
    </#if>
    </#list>
    </#list>