Virtual Endpoint URL Patterns

I’m trying out the virtual endpoints feature and having some difficulty to figure out how to configure the URL pattern matching properly.

I wanted to have two virtual endpoints: “GET /books” (to get a collection of books) and “GET /books/{id}” (to get a single book), both call two micro-services to fetch book information (book services) as well as supplementary information (cross-module meta data services), and the virtual endpoints aggregate results.

In my testing, requests like “GET /books/123” were routed to “GET /books” always, despite that I had specified the URL patterns clearly.

Any idea?


Hi Albert,

This might relate to the order in which the regexes were placed in your API definition. Tyk will run the first regex that matches the URL in question and then stop, so collection paths like /books will need to appear below member paths like /books/123 in order to work.

Hope that helps.

Kind regards,
Jess @ Tyk

Hi Jess,

Thanks for your prompt reply! I checked and the order was correct. It turned out that I accidentally used the same JS function name, which I guess resulted the latter (for /books) overwrote the former (for /books/{id}).

Anyway thanks for your help!

1 Like