Service Virtualization

  • 1.  how can i split an argument from request?

    Posted Jun 27, 2018 01:54 PM

    I am trying to split an argument from request to put into the response like the next example:

     

    The API requires to put the next format: 

    • city "," code of the country

     

    Like this:

     

    I know that using request_argument have the value

     

    But I want just the name of the city not the code of the country

     

    Is there any way to do it?

     

    I am usign CA Service Virtualization Community Edition.



  • 2.  Re: how can i split an argument from request?

    Posted Jun 27, 2018 05:22 PM

    I am wondering if using substring in the response would help you on this.

     

    Please, take a look at the posts below regarding substring:

    How to extract a substring of characters from a string spread across multiple lines? 

    Substring script in beanshell 

     

    Hope it helps.

    Heloisa



  • 3.  Re: how can i split an argument from request?
    Best Answer

    Broadcom Employee
    Posted Jun 27, 2018 06:02 PM

    Adding to what deoma03 mentioned above - please check if the following expression works in your case - where q is the incoming argument name.

     

    {{=request_q.substring(0,request_q.indexOf(","))}}



  • 4.  Re: how can i split an argument from request?

    Posted Jun 27, 2018 07:42 PM


    Sure, it was very helpful, another option is using split like this:

    • {{=request_q.split(",")[0]}} 

     

    Thanks for help me deoma03 and Prem_Bairoliya.