     json =
       queries: [name: 'QUERY', expression: query]
       region: region
-    uri += "?__json__=#{ encodeURIComponent (JSON.stringify json) }"
-    @request uri
+    @request URI(uri).setQuery '__json__', JSON.stringify(json)
     .then ({variant}) ->
       # We only support one query, so we flatten the query results.
       variant.coverage = variant.annotations.QUERY.coverage

    @request uri, method: 'DELETE'

  sample: (uri) =>
    @request uri + '?embed=user,groups'
    .then ({sample}) -> sample

  samples: ({filter, group, page_number}={}) =>
    uri = @uris.samples
    uri += "?user=#{ encodeURIComponent @current_user?.uri }" if filter == 'own'
    uri += '?public=true' if filter == 'public'
    uri += "?groups=#{ encodeURIComponent group }" if group?
    @collection uri, 'sample', {page_number}

  create_sample: (data) =>

    @request uri, method: 'DELETE'

  variations: ({sample, page_number}={}) =>
    uri = URI(@uris.variations).setQuery 'embed', 'data_source'
    uri.setQuery 'sample', sample if sample?
    @collection uri, 'variation', {page_number}

  variant: (uri, {query, region}={}) =>
