Forum Discussion

khill's avatar
khill
Mentor
7 years ago

Custom Tag Parameter in APIV2 GET call?

Hi everyone, Just want to make sure I am not missing anything obvious here.  Is there a way to call messages and include a custom_tag.text field?  I see that you can constraint the APIv2 calls by cu...
  • Jake_N's avatar
    7 years ago

    Hi khill,

    You are not missing anything. There is currently (here's hoping) no way to directly grab the custom_tags data except with the APIV2 query of :

    SELECT * FROM custom_tags WHERE messages.id='<insert message.id here>'

     If you want to grab the data and add it to your queries results, you can do something like this:

    <#assign mergedResults = [] >
    
    <#assign apiQuery = "SELECT id, custom_tags FROM messages WHERE post_time > [yesterday]" >
    <#assign apiResults =  rest("2.0", "/search?q="+apiQuery?url) >
    
    <#if apiResults.data.items?? >
    	<#list apiResults.data.items as message >
    		<#assign apiQuery2 = message.custom_tags.query >
    		<#assign apiResults =  rest("2.0", "/search?q="+apiQuery2?url) >
    		<#if apiResults2.data.items?? >
    			<#assign mergedResults += [message+{"custom_tags":apiResults2.data.items}] >
    		</#if>
    	</#list>
    </#if>

     

    Sources:
    APIV2 - Custom Tags