Layer7 API Management

Expand all | Collapse all

Special characters in URI

  • 1.  Special characters in URI

    Posted 02-14-2019 01:47 PM

    Hi.. Its just a weird thing am facing. I have this use case where i need to send a slash as part of id in uri. But generally it would mean resource, so i would be sending it as %2F. The weird thing is request is not reaching my proxy, but am getting 400 response from API gateway .  Say for example, service resolution path is /policies/*.  I need to fetch info of a policy called 75462/h0000. So my request path is /policies/75462%2Fh0000. What could be the reason? Do i need to apply any settings at gateway or proxy level? One interesting this my proxy works for other things like %20, %2D etc.. 

  • 2.  Re: Special characters in URI

    Posted 02-14-2019 05:22 PM

    Good afternoon,


    I can duplicate the issue in a 9.3 Gateway with the URI that you provided. The issue is that the / is a reserved character and really should be treated like a space or a - which you have seen work find. You could look to base64 the UserID to ensure that no device sees the / as part of the URI. Also if you pass through the URI without the conversion %2F then the gateway will accept it. You can modify the policy to take the last 2 sections of the URI to do policy logic.


    Sample policy to extract the userID from the URI:


    <?xml version="1.0" encoding="UTF-8"?>
    <wsp:Policy xmlns:L7p="" xmlns:wsp="">
    <wsp:All wsp:Usage="Required">
    <L7p:AutoTarget booleanValue="false"/>
    <L7p:CaptureVar stringValue="userID"/>
    <L7p:OtherTargetMessageVariable stringValue="request.http.uri"/>
    <L7p:Regex stringValue="/policies/(.*)"/>
    <L7p:RegexName stringValue="Compose ID"/>
    <L7p:Replacement stringValue=""/>
    <L7p:Target target="OTHER"/>
    <L7p:Base64ResponseBody stringValue="JHtyZXF1ZXN0Lmh0dHAudXJpfQoke3VzZXJJRFsxXX0="/>
    <L7p:ResponseContentType stringValue="text/plain; charset=UTF-8"/>




    Stephen Hughes

    Broadcom Support

  • 3.  Re: Special characters in URI

    Posted 02-15-2019 07:33 AM

  • 4.  Re: Special characters in URI

    Posted 02-18-2019 04:28 AM

    Thanks Joe. This helps really.

    I am little more curious that why this is not enabled default and why CA API gateway is returning Bad request? will it have any impact on enabling? 

    Brief explanation is appreciable.