Submitting a form programatically

I’m trying to create a registration form via a mobile app based on this tutorial http://www.wembassy.com/blog/chris-mcintosh/create-angularjs-headless-dr…. It involves posting the Register form parameters to a custom url and then sumbitting the user registration form using the Form API as follows: $form_state = (new FormState())->setValues($_POST); Drupal::formBuilder()->submitForm(‘DrupaluserRegisterForm’,[…]