Forum Discussion

dhiraj_gophane's avatar
9 years ago
Solved

Get all ideas in community posted in last 30 days

Hi All,

 

We need to fetch ideas for last 30 days from whole comminity using REST API call. Could you please let us know.

 

Regards,

Dhiraj

8 Replies

  •  

    dhiraj_gophane I hope this will help you.

    <#assign apiVersion = "2.0"/>
    <#assign ideaQuery = "select * from messages where conversation.style='idea' and depth=0"/>
    <#assign ideas = rest(apiVersion, "/search?q=" + ideaQuery?url+ 
    "&max_age=one_month").data.items/>

    Give kudos if you find my post helpful.

     

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)
    9 years ago

    You will also need to paginate (in case the number goes above the maximum returned by a single REST call) - in LIQL this can be done using the OFFSET and LIMIT syntax. 

  • Hi TariqHussainPaoloT,

     

    Thank you for the inputs. 

     

    Could you please cofirm if we can do this call from external JAVA app. If yes, could you please let us know if there are any specific changes needed to the API call?

     

    Regards,

    Dhiraj

  • TariqHussain's avatar
    TariqHussain
    Boss
    9 years ago

    dhiraj_gophane i am not sure about this but please check this link Link. or you also can make endpoint and can call to that endpoint from external app.

  • dhiraj_gophane's avatar
    dhiraj_gophane
    Leader
    9 years ago

    Hi TariqHussain,

     

    I'm trying to get response in endpoint but it seems that the max_age parameter is not supported by mentioned call. I'm using followiung code but getting count of all ideas in community, instead of last one month.

     

    <#assign apiVersion = "2.0"/>
    <#assign ideaQuery = "select * from messages where conversation.style='idea' and depth=0 LIMIT 1000 OFFSET 0 "/>
    <#assign ideas = rest(apiVersion, "/search?q=" + ideaQuery?url+
    "&max_age=one_month").data.items/>

    ${ideas?size}

     

    Please let me know your comments.

     

    Regards,

    Dhiraj

  • dhiraj_gophane's avatar
    dhiraj_gophane
    Leader
    9 years ago

    Hello Everyone,

     

    Following REST call worked for me which I got from support team. 

     

    SELECT * FROM messages WHERE conversation.style = 'idea' AND conversation.last_post_time > 2015-12-01T10:04:30-08:00
    AND conversation.last_post_time < 2015-12-31T10:04:30-08:00 AND depth=0 ORDER BY conversation.last_post_time DESC

     

    Also followiong article is helful,

    http://community.lithium.com/t5/Community-API-v2/Message-resource/ta-p/113091

     

    Regards,

    Dhiraj

  • irach15's avatar
    irach15
    Maven
    9 years ago

    dhiraj_gophane,

    you input a date,

    can you do it without specific dates, just any month...

    Last 30 days can be any time frame from now, not specific.

    Thanks.

     

  • dhiraj_gophane's avatar
    dhiraj_gophane
    Leader
    9 years ago

    irach15: To use above rest call you need to give timeframe in date format. If you need code to get date before "n" number of dates then I can provide it. Let me know.