Forum Discussion

pkrish80's avatar
pkrish80
Contributor
12 years ago

how to get data returned by rest api call based on timestamp

Hi All,

 

I am using a REST Api in my Java Code as a part of the HP Community. I am able to retrieve all the messages from the posts. I would like to know how can I use this api to get messages between a certain timestamp or dates. I am getting the "recent" ones as shown in the api below. Please let me know when you have a chance.

 

http://<<hpcommunity>>/restapi/vc/boards/id/Ink/posts/recent?page_size=100&page=1&restapi.response_format=json&restapi.format_detail=full_list_element&restapi.response_style=view

 

Thanks

4 Replies

  • Hi All,

     

    This is what I am using to get the range of messages in the last month sorted by post_time.

     

    http://<<communityname>>/restapi/vc/boards/id/"+categoryType+"/posts/recent?rangeTime=1M&sort_by=-post_time&page_size="+numOfCalls+"&page="+pageNum+"&restapi.response_format=json&restapi.format_detail=full_list_element&restapi.response_style=view

     

    This doesn't seem to work. Can someone chime in on this?

     

    Thanks,

    Prasanna

  • NicoB's avatar
    NicoB
    Lithium Alumni (Retired)
    12 years ago

    Hi pkrish80 

    What about this call:

    http://community/restapi/vc/search/messages?q=board_id:ID%20AND%20latestPostDate:[1234567%20TO%2012344567]&sort_by=-topicPostDate

     

    Please not that you would need to calculate the latestPostDate parameter which specify in interval in millisecond. Freemarker has functions for performing transformations to get milliseconds of a date (http://community.lithium.com/t5/Developers-Knowledge-Base/datesupport-FreeMarker-context-object/ta-p/9349).

     

    Thanks,

    Nico

     

  • pkrish80's avatar
    pkrish80
    Contributor
    12 years ago

    Hi Nico,

     

    The api parameters do not seem to work. Any other suggestions?

     

    Thanks,

    Prasanna

  • NicoB's avatar
    NicoB
    Lithium Alumni (Retired)
    12 years ago

    Hi pkrish80 

    I've tried with this call and it seems to work:

    http://community.lithium.com/restapi/vc/search/messages?q=board_id:studio%20AND%20date:[1402229189%20TO%201404821189]&sort_by=date

     

    Bear in mind that I was wrong about the timestamp.

    The date parameter actually needs to be specified in seconds since epoch.

    You can calculate this using for example this website http://www.epochconverter.com/

     

    Thanks,

    Nico