What do I put as my target URL if I want it to hit my virtual endpoint?

Howdy,

I needed 2 different target URLs for a route in the tyk gateway, so I saw that I could simply create a virtual endpoint, in which a JS function makes 2 separate fetch requests to 2 separate APIs, and returns the results.

I set up a virtual endpoint POST route, which should call a virtual path executing JS code. In the settings, I made sure POST was one of the allowed methods.

The thing is, when I call a POST on that route, it says POST isn’t allowed. As i understand it, its because the default target url, httpbin, doesnt allow POST. So it seems like its hitting httpbin instead of my virtual endpoint, which is weird since it should hit the route I set up my endpoint in.

My question is, what do I put as my target URL if I want it to hit my virtual endpoint, instead of httpbin?

Hi Mark,

Thanks for using Tyk.

To answer your question, you need to call the full path of the virtual endpoint. The full path comprises of your {API URL} + {your virtual endpoint path}

I have attached an image that references 2 virtual endpoints below

For example, if I have an API URL at http://www.tyk-test.com:8080/httpbin-test that makes a simple GET call the http bin URL

Calling my virtual endpoint would look like

However, could you share your API definition for review and redact any sensitive information in it. From your statement, it appears you may have gotten the GET virtual endpoint working already

Hi, thank you for helping me out, I appreciate it.

I used the API url as my target URL, made a test request in the debugging console and got this:

Surprised I’m not getting the expected JSON response

Is there anyway we could potentially get on a zoom call? It would certainly be helpful

Hello @Mark ,

If you want to use a virtual endpoint and you want that to be the only functionality of the API you can enter anything for the target URL http://foo for example.

You then will need to follow @Olu’s example and create the virtual endpoint under a specific endpoint path for that API and add a whitelist plugin to disallow access to any of the other endpoints of the API.

If you are still looking for someone to jump on a zoom call with you I am available in the next hour. If that does not work we can do tomorrow as well.

Regards,
Zaid