I am wondering is it possible for Tyk to add in a request header?
Let’s say I have an API and want to proxy through Tyk. And in this API, I want Tyk to inject a request header when I call this API.
Is it possible to do that in Tyk?
Yes that’s possible in Tyk.
You can set it such that Tyk injects a header anytime the API is called. You can also set it such that Tyk only injects a header when a specific endpoint in the API is called.
See here for details: Request Headers
Let me know if this helps.
Thanks for your help.
I did that in Tyk dashboard, where for testing purpose, I added a header called ‘InjectHeader’, and the value is “Injection”.
But when I called this API, I don’t see this header being injected into the request header.
How do you see this injected header in this API, when you call it?
You can see the request headers when you check the log browser after calling the API.
You first need to enable detailed logging on the API.
Then check the log browser.
Alternatively, with an upstream/target url of httpbin.org, you can inspect the request headers when you GET httpbin.org’s “/headers” endpoint
Thanks for your help! It helps me a lot!
If I don’t use this Tyk log browser, is there any other way to see this injected header?
Is it possible to see this injected header in curl or Postman?
Hmm curl or Postman, not that I’m aware of, no. The request transformation is done within Tyk, after the request has “left” curl/postman, so curl/postman wouldn’t be aware of the changes.
You’d need a service on the receiving end, to inspect the received request, an example of which is httbin.org, as mentioned earlier.
You could also use a request plugin (implemented in the right place in the request middleware chain) to see the injected header.
Noted. Thanks for your help!