Layer7 API Management

  • 1.  validate request url

    Posted Dec 17, 2018 05:29 AM

    How to extract any specific part of URL path and it must be configurable. i know that context variable http.url.path gives whole url path. But my requirement is, say for example my rest url path is /services/{id}/accounts/{accountId} and i need to extract id and accountId from the path. The extraction data and its position in URL path changes for every operation. can anyone help me in this?



  • 2.  Re: validate request url

    Broadcom Employee
    Posted Dec 17, 2018 08:57 AM

    Hello,

     

    I would recommend using RegEx to parse the URL or alternatively using the split variable assertion against ${request.url.path}.

     

    The split assertion will produce a multivalued context variable that can be reference by index.

     

    Split Variable Assertion - CA API Gateway - 9.4 - CA Technologies Documentation 

     

    Regards,

    Joe



  • 3.  Re: validate request url

    Posted Dec 17, 2018 09:28 AM

    Thanks for the response. I am trying to use regex to parse the url. so, any example which solves my problem would be appreciable.



  • 4.  Re: validate request url
    Best Answer

    Broadcom Employee
    Posted Dec 17, 2018 10:04 AM

    If you are simply looking for numeric values you can use something like \d or [0-] against request.url.path.

     

    The output with these options will be a MV context variable as with the split. This may need to be a little more elaborate though in the case that the url is something like /id/name/accountID = /1/name32/2923

    name23 would be caught here as well.

     

    The split may provide a more efficient solution. 

     



  • 5.  Re: validate request url

    Posted Dec 17, 2018 12:51 PM

    Thanks for the example.