search cancel

CA API Management: How to handle URL Hash Fragments


Article ID: 16682


Updated On:


STARTER PACK-7 CA Rapid App Security CA API Gateway


How can the Gateway handle URL Hash Fragments? In the below example I would like to retrieve the value of product.




Release: L7SGA299000-8.4-API Gateway SOA Gateway-HARDWARE APPLIANCE DUAL CPU


The hash fragments of a URL are not sent to the server (Gateway) and will need to be handled via the user agent using a client side language such as JavaScript.

For this purpose you can use a 'Return Template Response to Requestor' assertion.


You can use JavaScript to convert the hash fragment to a query parameter (which the Gateway can see) and redirect the request back to the Gateway.

This can be accomplished using the below code within a return template response. It will retrieve the first hash value and send the browser back to the same service appending the hash as ?product=Gateway. This can now be utilized with the ${request.http.parameter.product} built-in context variable and can be used within policy to manipulate the value.


<script type="text/javascript">

if (window.location.hash.length != 0) {

var queryString = location.hash.substring(1);

window.location = "${request.url.protocol}://${}:${request.url.port}${request.url.path}?" + queryString