Forum Discussion

isxtn's avatar
isxtn
Advisor
2 years ago

Returning all messages with a certain tag?

I'd like to return all the top level messages given a single tag, with results that include the id, user, body, subject, and post time. Is there a better way? Or even a way that works? 

Attempt 1 with "foo" I keep getting an error when doing this in V1. 

<#assign taggedMsgs = rest("/tagging/for/tags/text/Event/messages").messages />

 

Error: 

REST Error:
 path="https://[communityname]/restapi/vc/tagging/for/tags/text/foo/messages?restapi.response_style=view"
 status="error"
 code="504"
 message="Method 'post' is not supported off of node 'generic_tagging_context.messages'."

 

Attempt 2 with "foo": search

 

<#assign taggedMsgs = rest("/search/messages?q=tags:foo").messages/>

 

but it only returns a messages with a limited number of fields available, which does not include body, view_href, or many others. How can I get those fields as well? 

Returned data:

<response status="success">
<messages>
<message type="message" href="/messages/id/28497">
<root type="message" href="/messages/id/12345"/>
<canonical_url type="string" null="true"/>
<post_time type="date_time">2023-07-26T09:49:55+00:00</post_time>
<message_rating type="float">0.0</message_rating>
<last_edit_author type="user" href="/users/id/123">
<login type="string">SomeUser</login>
</last_edit_author>
<kudos>
<count type="int">0</count>
</kudos>
<last_edit_time type="date_time">2023-08-02T16:00:24+00:00</last_edit_time>
<labels/>
<seo_title type="string" null="true"/>
<seo_description type="string" null="true"/>
<author type="user" href="/users/id/123">
<login type="string">LoginName</login>
</author>
<deleted type="boolean">false</deleted>
<board type="board" href="/boards/id/123"/>
<thread type="thread" href="/threads/id/12345"/>
<parent type="message" null="true"/>
<teaser type="string"/>
<views>
<count type="int">17</count>
</views>
<board_id type="int">2</board_id>
<subject type="string">Revolutionizing Technology and Innovation: Exploring the Boundless Horizons of Cutting-Edge Advancements in the Digital Era</subject>
<id type="int">12345</id>
<read_only type="boolean">false</read_only>
</message>
</messages>
</response>

 

  • Sweet. I didn't even realize that we could get messages by tags from V2 without a message.id constraint.

    While I'm here, MattV , is there a way to list all Settings for a site, either in V1 or V2? Specifically I want to see the names and values for the settings in the Settings List Editor, not for a user. 

    i.e., these kind of settings

     

    ${coreNode.settings.name.get("profile.language", "en")}
    ${coreNode.settings.name.get("custom.discussion_category_id", "nada")}

     

    Etc

    Thanks!

    • isxtn's avatar
      isxtn
      Advisor

      Sweet. I didn't even realize that we could get messages by tags from V2 without a message.id constraint.

      While I'm here, MattV , is there a way to list all Settings for a site, either in V1 or V2? Specifically I want to see the names and values for the settings in the Settings List Editor, not for a user. 

      i.e., these kind of settings

       

      ${coreNode.settings.name.get("profile.language", "en")}
      ${coreNode.settings.name.get("custom.discussion_category_id", "nada")}

       

      Etc

      Thanks!

      • MattV's avatar
        MattV
        Khoros Staff

        There isn't a way to just get a list of all the settings, but all settings can be retrieved with APIv1, just one at a time.

        It's not particularly well documented, but you can do /settings/name/custom.discussion_category.id for example. You can also do this off of a user node, category or board....

        /boards/id/myboard/settings/custom.setting_name

        /category/id/mycategory/settings/custom.setting_name

        /users/id/userid/settings/setting.name