Error rest_post_invalid_page_number trying to call Rest API

I don’t know why yet, but I had the same issue until I disabled a filter on pre_get_posts.

What I’m doing here is retrieve all recipe custom post type when I’m on the home page :

// add_filter( 'pre_get_posts', 'my_get_posts' );

function my_get_posts( $query )
{
    if ( is_home() && $query->is_main_query() )
        $query->set( 'post_type', array( 'recipe' ) );
        $query->set( 'posts_per_page', -1 );

    return $query;
}

Try to know if you’re hijacking a main query like I did, I’ll do more research on the “why” 🙂