I want to create an API in API Connect such that the API will be able to modify the incoming request to include a new header on top of the existing header and this information will be extracted from the gateway URL. If the gateway URL is https://api.us.apiconnect.ibmcloud.com/cloud-microservices-unit-dev/sb, then the extra field(say 'env') added to the request message header will contain env=us.
Asked
Active
Viewed 1,312 times
-2
-
True for fetching the catalog address I can do what you have said. But if you check my post my main concern was to modify the request message header. How to add a new field in the request message header in API Connect gatewayscript policy? @EliShere – Aritra Dasgupta Oct 31 '19 at 13:25
1 Answers
0
Looks like you require the catalog name.
You can either use the env.path
context variable (v5 compatible mode only) or split and take the 2nd argument of the host header using request.headers.host
context variable.
See https://www.ibm.com/support/knowledgecenter/en/SSMNED_2018/com.ibm.apic.toolkit.doc/rapim_context_var.html for more information.

EliSherer
- 1,597
- 1
- 17
- 29
-
True for fetching the catalog address I can do what you have said. But if you check my post my main concern was to modify the request message header. How to add a new field in the request message header in API Connect gatewayscript policy? – Aritra Dasgupta Oct 31 '19 at 13:25
-
see example here: https://www.ibm.com/support/knowledgecenter/SSFS6T/com.ibm.apic.toolkit.doc/rapim_gwscript_codesnip.html – EliSherer Nov 02 '19 at 07:09