Forum Discussion

Gursimrat's avatar
Gursimrat
Leader
11 years ago

Error while reading the message Body and Labels

Hi Everyone,

 

I am trying to get the TKB articles from a category, everthing is working fine but I am getting a strange error, when I try to get the Body and the Labels, I get an error: When and why do we get this error?

 

For "${...}" content: Expected a string or something automatically convertible to string (number, date or boolean), but this evaluated to a sequence+hash (wrapper: f.e.dom.NodeListModel):
==> tkb_details.messages.topic.body  [in template "authoritative_content_category_ot" at line 7, column 172]

The failing instruction (FTL stack trace):
----------
==> ${tkb_details.messages.topic.body}  [in template "authoritative_content_category_ot" at line 7, column 170]
----------

 


My Code to read the Body and Labels: The highlighted ones give error

<#assign get_tkb = rest("categories/id/${coreNode.id}?restapi.response_style=view").category.boards>
<#list get_tkb.board as tkb_board_id>
<#if tkb_board_id.interaction_style == "tkb" >
<#assign tkb_articles = rest("boards/id/${tkb_board_id.id}/threads?restapi.response_style=view").threads>
<#list tkb_articles.thread as tkb_details>
${tkb_details.messages.topic.id} - ${tkb_details.messages.topic.subject}, ${tkb_details.messages.topic.last_edit_author.login} - ${tkb_details.messages.topic.body} - ${tkb_details.messages.topic.labels.label.text}  <br>
</#list>
</#if>
</#list>  

 


The XML response is as below:

 

<response status="success">
<thread type="thread" href="/threads/id/119" view_href="http://community.demo.com/t5/demo-Gifts/What-is-demo-Gifts/ta-p/119">
<solutions/>
<messages>
<count type="int">1</count>
<topic type="message" href="/messages/id/119" view_href="http://community.demo.com/t5/demo-Gifts/What-is-demo-Gifts/ta-p/119">
<board_id type="int">1</board_id>
<root type="message" href="/messages/id/119" view_href="http://community.demo.com/t5/demo-Gifts/What-is-demo-Gifts/ta-p/119"/>
<message_status type="message_status" href="/message_statuses/id/1">
<name type="string">Unspecified</name>
<key type="string">unspecified</key>
</message_status>
<post_time type="date_time" view_date="03-05-2014" view_time="06:06 PM" view_friendly_date="">2014-03-06T02:06:36+00:00</post_time>
<last_edit_time type="date_time" view_date="03-05-2014" view_time="06:06 PM" view_friendly_date="">2014-03-06T02:06:36+00:00</last_edit_time>
<parent type="message" null="true"/>
<teaser type="string"/>
<views>
<count type="int">5</count>
</views>
<labels>
<label type="label" href="/labels/id/11">
<id type="int">11</id>
<text type="string">demo Gifts</text>
</label>
</labels>
<kudos>
<count type="int">0</count>
</kudos>
<message_rating type="float">0.0</message_rating>
<last_edit_author type="user" href="/users/id/53" view_href="http://community.demo.com/t5/user/viewprofilepage/user-id/53">
<login type="string">Caty</login>
</last_edit_author>
<body type="string">
<DIV class="lia-message-template-content-zone"><P>&nbsp;</P> <P>demo Gifts is a service that allows people to purchase digital gift cards for use at participating demo restaurants. The gift card is immediately delivered to the recepient via email, and does not have an expiration date.</P> </DIV>
</body>
<thread type="thread" href="/threads/id/119" view_href="http://community.demo.com/t5/demo-Gifts/What-is-demo-Gifts/ta-p/119"/>
<board type="board" href="/boards/id/demo-gifts" view_href="http://community.demo.com/t5/demo-Gifts/tkb-p/demo-gifts"/>
<subject type="string">What is demo Gifts?</subject>
<id type="int">119</id>
<read_only type="boolean">false</read_only>
<deleted type="boolean">false</deleted>
<author type="user" href="/users/id/53" view_href="http://community.demo.com/t5/user/viewprofilepage/user-id/53">
<login type="string">Caty</login>
</author>
</topic>
<read>
<count type="int">1</count>
</read>
<linear>
<message type="message" href="/messages/id/119" view_href="http://community.demo.com/t5/demo-Gifts/What-is-demo-Gifts/ta-p/119">
<board_id type="int">1</board_id>
<root type="message" href="/messages/id/119" view_href="http://community.demo.com/t5/demo-Gifts/What-is-demo-Gifts/ta-p/119"/>
<message_status type="message_status" href="/message_statuses/id/1">
<name type="string">Unspecified</name>
<key type="string">unspecified</key>
</message_status>
<post_time type="date_time" view_date="03-05-2014" view_time="06:06 PM" view_friendly_date="">2014-03-06T02:06:36+00:00</post_time>
<last_edit_time type="date_time" view_date="03-05-2014" view_time="06:06 PM" view_friendly_date="">2014-03-06T02:06:36+00:00</last_edit_time>
<parent type="message" null="true"/>
<teaser type="string"/>
<views>
<count type="int">5</count>
</views>
<labels>
<label type="label" href="/labels/id/11">
<id type="int">11</id>
<text type="string">demo Gifts</text>
</label>
</labels>
<kudos>
<count type="int">0</count>
</kudos>
<message_rating type="float">0.0</message_rating>
<last_edit_author type="user" href="/users/id/53" view_href="http://community.demo.com/t5/user/viewprofilepage/user-id/53">
<login type="string">Caty</login>
</last_edit_author>
<thread type="thread" href="/threads/id/119" view_href="http://community.demo.com/t5/demo-Gifts/What-is-demo-Gifts/ta-p/119"/>
<board type="board" href="/boards/id/demo-gifts" view_href="http://community.demo.com/t5/demo-Gifts/tkb-p/demo-gifts"/>
<subject type="string">What is demo Gifts?</subject>
<id type="int">119</id>
<read_only type="boolean">false</read_only>
<deleted type="boolean">false</deleted>
<author type="user" href="/users/id/53" view_href="http://community.demo.com/t5/user/viewprofilepage/user-id/53">
<login type="string">Caty</login>
</author>
</message>
</linear>
</messages>
<title type="string" null="true"/>
<board type="board" href="/boards/id/demo-gifts" view_href="http://community.demo.com/t5/demo-Gifts/tkb-p/demo-gifts"/>
<id type="int">119</id>
<interaction_style type="string">tkb</interaction_style>
</thread>
</response>
 

 

  • Used this instead:

     

    <#assign tkb_body = rest("messages/id/${tkb_details.messages.topic.id}/body").value>
    <#assign tkb_labels = rest("messages/id/${tkb_details.messages.topic.id}/labels").labels>

1 Reply

  • Used this instead:

     

    <#assign tkb_body = rest("messages/id/${tkb_details.messages.topic.id}/body").value>
    <#assign tkb_labels = rest("messages/id/${tkb_details.messages.topic.id}/labels").labels>