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 custom_tag.text, but not that you can add it into the call fields.

Going for something like this: SELECT id, custom_tag.text WHERE post_time > [yesterday] 

Thanks in advance for the help!

Kate

 

  • 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

  • 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

    • khill's avatar
      khill
      Mentor

      Thanks so much Jake_N for both validating that I didn't miss anything AND providing such a good example of how I can workaround.

       

      Very appreciated!

      Kate