Forum Discussion

peterlu's avatar
peterlu
Champion
12 years ago

rest api - search blog by label

Hi Guys,

 

User case:

A blog has 3 labels set "Apple", "Banana", "Test Space"

 

Here are the rest calls that works:

/search/messages?q=is_root:true%20AND%20labels:(Apple)&include_blogs=true
/search/messages?q=is_root:true%20AND%20labels:(Apple%20OR%20Banana)&include_blogs=true

  

Here is the rest call that does not work:

/search/messages?q=is_root:true%20AND%20labels:(Test%20Space)&include_blogs=true

 Any idea?

 

What is the format for labels with spaces?

 

Thanks

  • I'm not sure exactly why this occurs, but I've worked around similar issues in the past by replacing the space with %3F, which is the encoded form of ?. In the search query, the question mark character represents a single-character wildcard and seems to do the trick.

  • I would also try with %22Test%20Space%22 , where %22 is the encoding for " (although I haven't tried that myself so I am not 100% sure)
  • Good question - I did a little experiment, including replacing the space with a + or %2B, but couldn't get any results.

     

    AdamN, PaoloT - do you know how to search for labels with spaces in them?

    • AdamN's avatar
      AdamN
      Khoros Oracle

      I'm not sure exactly why this occurs, but I've worked around similar issues in the past by replacing the space with %3F, which is the encoded form of ?. In the search query, the question mark character represents a single-character wildcard and seems to do the trick.

      • PaoloT's avatar
        PaoloT
        Lithium Alumni (Retired)
        I would also try with %22Test%20Space%22 , where %22 is the encoding for " (although I haven't tried that myself so I am not 100% sure)