Transform headers with version data

Hi,

I am trying to get a header removed and another added under the version but for some reason its not working. I added the code for both transform_headers and transform_response_headers but that didnt help

Trying to Remove the “Authorization” header from the incoming message
Then Add header “TykApiToken” with value “123456"”

{
"name": "Test API",
"slug": "test-api",
"api_id": "100",
"org_id": "100",
    .......
"version_data": {
	"not_versioned": false,
	"versions": {
		"v1": {
			"name": "v1",
			"expires": "",
			"use_extended_paths": true,
			"extended_paths": {
				"ignored": [],
				"white_list": [],
				"black_list": []
			},
			"global_headers": {},
			"global_headers_remove": [],
			"global_size_limit": 0,
			"use_extended_paths": true
		},
		"v2": {
			"name": "v2",
			"expires": "",
			"use_extended_paths": true,
			"extended_paths": {
				"transform_headers": [
					{
						"add_headers": {
							"TykApiToken": "123456"
						},
						"delete_headers": [
							"Authorization"
						]
					}
				],
				"transform_response_headers": [
					{
						"add_headers": {
							"TykApiToken": "123456"
						},
						"delete_headers": [
							"Authorization"
						]
					}
				],
				"ignored": [],
				"white_list": [
					{
						"path": "/v2/allowed/",
						"method_actions": {
							"GET": {
								"action": "no_action"
							}
						}
					}
				],
				"url_rewrites": [
					{
						"path": "/*",
						"method": "GET",
						"match_pattern": "\/v2\/allowed\/(\\w+)\/(\\w+)",
						"rewrite_to": "https://10.100.10.10/smart/api/v1/cisco/1",
						"triggers": [],
						"MatchRegexp": null
					}
				],
				"black_list": []
			},
			"global_headers": {
			},
			"global_headers_remove": [],
			"global_size_limit": 0
		}
	},
	"default_version": "v2"
},
"proxy": {
	"listen_path": "/smart-api/",
	"target_url": "https://10.10.10.10",
	"strip_listen_path": true
},
"active": true
}

when i place the code under global it works as expected …

				"url_rewrites": [
					{
						"path": "/*",
						"method": "GET",
						"match_pattern": "\/v2\/allowed\/(\\w+)\/(\\w+)",
						"rewrite_to": "https://10.10.10.10/smart/api/v1/cisco/1",
						"triggers": [],
						"MatchRegexp": null
					}
				],
				"black_list": []
			},
			"global_headers": {
				"TykApiToken": "12345"
			},
			"global_headers_remove": [],
			"global_size_limit": 0
		}
	},
	"default_version": "v2"

Can anyone spot why this is the case?

Thanks
alexis

Hi Alexis,

the definition is missing a couple of keys in the “transform…” object, i’d suggest to go through our documentation here.

Thanks,
Kos