0

I have an API route that should accept more than one parameter, but it seems that only one parameter is being recognised, like this:

new Route(
  ['POST'],
  'v1/myapiendpoint/:nr/:id',
  'mycomponent.mycontrolerfunction',
  ['nr' => '(\d+)', 'id' => '(\d+)' ],  // more than one parameter not recognized?!
  [
     'component' => 'com_mycomponent',
     'public'    => false
  ]
)

How can I define routes with more than one parameter? Is this even possible?

1 Answer 1

2

There is an error in router documentation. Capture group brackets are actually added automatically. So you shouldn't use them in your patterns:

['nr' => '\d+', 'id' => '\d+']
1
  • Thank you very much for the hint. It works.
    – cappu
    Commented Dec 5, 2023 at 9:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.