title: WP_REST_Request return rest_no_route (404) for custom endpoint
body: <p>I created a custom endpoint for the WordPress API-REST. I can access it normally via browser. But when I try to access it via WP_REST_Request, I get a message of &quot;rest_no_route (404)&quot;</p>
  <pre><code>&lt;?php 
  
  add_action( 'rest_api_init', 'custom_routes_rifa');
  
  function custom_routes_rifa(){
  
      
      register_rest_route(
        'pluginrifa/v2', '/infos/', array(
          'methods'       =&gt; 'GET',
          'callback'      =&gt; 'api_rifa_infos',
          'show_in_index' =&gt; false
        )
      );
  
  }
  </code></pre>
  <p>If I put /wp-json/pluginrifa/v2/infos/?rifa=140 in the browser everything works as it should, but the code below returns 404:</p>
  <pre><code>&lt;?php
  $request = new WP_REST_Request( 'GET', '/wp-json/pluginrifa/v2/infos' );
  $request-&gt;set_query_params( [ 'rifa' =&gt; 140 ] );
  $response = rest_do_request( $request );
  $server = rest_get_server();
  $data = $server-&gt;response_to_data( $response, false );
  $json = wp_json_encode( $data );
            
  $obj = json_decode($json);
  </code></pre>
  <p>I found this discussion <a href="https://stackoverflow.com/questions/36645019/custom-route-endpoint-for-wp-rest-api-gives-code-rest-no-route-error">Custom route endpoint for WP-REST API gives &quot;code&quot;: &quot;rest_no_route&quot;, error</a> but none of the proposed solutions resolved, apart from apparently be something different, as it works via HTTP, but via WP_REST_Request it doesn't.</p>