Forum Discussion

venuj1244's avatar
venuj1244
Contributor
12 years ago

Can any body suggest me how can i check no posts returned for threadID ?

 

I am trying to do a check if thread exists with the given threadID, I am making the API call through restadmin ("/threads/id/"+threadID). . I am not able to figure out one thing.

 

I tried checking it with below calls to find if no posts returned for the passed thread ID ( Ex: Assuming thread ID exists in the Knowledge but no posts returned from end point) but these calls did not help me to findout same.

 

  • restadmin("/threads/id/"+thread).@status =”error”
  • restadmin("/threads/id/"+thread)?size=0
  • restadmin("/threads/id/"+thread).error?size=1
  •  

 

restadmin("/threads/id/"+thread) call is throwing an error

  • YuriK's avatar
    YuriK
    Khoros Expert

    Hey Venuj,

     

    What you would probably want to do is use attempt/recover.

     

    <#attempt>
    <#assign thread=restadmin("/threads/id/20")>
    <#recover>
    ${.error}
    </#attempt>

     The ${.error} will contain the error string thrown by the call.

     

    Hope this helps,

     

    Yuri

  • YuriK's avatar
    YuriK
    Khoros Expert

    Out of curiosity, why would you need to check whether a thread exists based on a threadID?

     

    Thank you,

     

    Yuri