Forum Discussion

Gursimrat's avatar
Gursimrat
Leader
12 years ago

Need help with TemplateModelException as a result of REST API call

[Mod Note: This post was originally submitted as a comment to this TKB article: Re: Context objects for custom components - rest]

 

I am getting TemplateModelException by making following rest call

 

<#assign messages_list = restadmin("/boards/id/"+coreNode.id+"/messages/linear")>

 

Can you help me out?

1 Reply

  • In what page/node are you including this content? The variable coreNode.id will be replaced with the ID of the current node. So if you have this on a page/node that is at the Community level, the value of coreNode.id will be your high level community, and since that isn't a Board, you will get an exception.

     

    If you include it in a page that is a board, then I think it should work.  Alternatively, if you want to put it on a custom page and display the messages from a specific board (e.g. a board with id 'board-1'), you could use the following call:

     

    <#assign messages_list = restadmin("/boards/id/board-1/messages/linear")>

     If you don't need to execute the call as a privileged user, you could do the following instead:

     

    <#assign messages_list = rest("/boards/id/board-1/messages/linear")>

    Hope this helps.