fix query code.

It looks like we need to interpolate the query strings,
I got an error with character literals. Also, the 'api'
object gives us the 'ref'.