Is it possible for Tyk to add in request header?

Hi,

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?

Regards,

Maan Tarng

Hi @maantarng,

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.

Hi @Ubong

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?

Regards,

Maan Tarng

Awesome.

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

Hi @Ubong

Thanks for your help! It helps me a lot!

Regards,

Maan Tarng

Hi @Ubong

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?

Hey @maantarng,

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.

Hi @Ubong

Noted. Thanks for your help!