Layer7 API Management

 View Only
  • 1.  Trim white spaces in Split Variable Assertion

    Posted Oct 16, 2017 09:27 AM

    Hi guys I am working of API Gateway 9.1

    I have an Json Response, I am using Evaluate JSON assertion(prefix is jsonData) & getting multiple values. 

    Ex: ${jsonData.results} gives all values as a1, b2, c3

     

    Then I am using Split variable (ex: variable - split) to split using comma (,)

    It is spiting with the white-space after comma(,) In Audit logs I can see the spitted values with space after comma

     

     

    Then I am using Run Assertions for Each Item Assertion with HTTPS Route,

    http://abc.foo.com/${split}

    https://abc.foo.com/ c3

    (There is space between / & c3)

     

    I get an error because the space in between the. How can i remove/trim the space?

     

    Thanks,

    Siddharth



  • 2.  Re: Trim white spaces in Split Variable Assertion
    Best Answer

    Broadcom Employee
    Posted Oct 16, 2017 06:05 PM

    Hello siddharth-b ,

    You can use regex to trim the white spaces before use it, as shown below, leave "Replacement" empty.

    NOTE: it will trim the white spaces in the middle as well,

    if only trim beginning white space
    ^\s+
    if only trim ending whitespace
    \s+$

    if you want both, use 2 regex.

     

     

    Regards,

    Mark