Custom post type REST api 404: Updating failed. No route was found matching the URL and request method

The registration code was called inside the is_admin(). Moving the code outside solved the issue.

/*if(is_admin())
{*/
$this->sconfig= ['post_type'=> 'event', 'slug'=>'events'];
add_action('init', array($this, 'register_event_posttype'));
/*}*/