Forum Discussion

Harshz6693's avatar
Harshz6693
New Contributor
7 years ago
Solved

How to remove extra slash in Request URL when EndPoint = ${#Project#EndPoint} using groovy ?

Hi,
I am not able to set the Endpoint to be ${#Project#Endpoint} in groovy, because if set in this way , SoapUI sets the URL to start with  http:///  which consists of 3 slashes after http.
If I set the Endpoint to  http://${#Project#Endpoint} , then SoapUI drops/breaks the data after # giving it as  http://${.
Is there any other method to set the endpoint to ${#Project#Endpoint}

 

Thanks!

  • Solution:  Set the Endpoint property value seperately.

    Before :  String EndPoint = "\${#Project#Endpoint}"  OR  String EndPoint = "http://\${#Project#Endpoint}" 

     

                   testStep = testCase.addTestStep(type: "httprequest",  name: "abc", endpoint: "EndPoint" + "/xml"  , method:  "POST")

     

    Output:  Request URL:  http:///${#Project#Endpoint}/xml  ==> http contained 3 slashes

     

    After applying solution:

                   String EndPoint = "http://\${#Project#Endpoint}"

     

                    testStep = testCase.addTestStep(type: "httprequest",  name: "abc", endpoint: " "  , method:  "POST")

     

                   testStep.setPropertyValue( "Endpoint",  "EndPoint" + "/xml")

     

    Output Request URL:   http://${#Project#Endpoint}/xml
                

                    

1 Reply

  • Harshz6693's avatar
    Harshz6693
    New Contributor

    Solution:  Set the Endpoint property value seperately.

    Before :  String EndPoint = "\${#Project#Endpoint}"  OR  String EndPoint = "http://\${#Project#Endpoint}" 

     

                   testStep = testCase.addTestStep(type: "httprequest",  name: "abc", endpoint: "EndPoint" + "/xml"  , method:  "POST")

     

    Output:  Request URL:  http:///${#Project#Endpoint}/xml  ==> http contained 3 slashes

     

    After applying solution:

                   String EndPoint = "http://\${#Project#Endpoint}"

     

                    testStep = testCase.addTestStep(type: "httprequest",  name: "abc", endpoint: " "  , method:  "POST")

     

                   testStep.setPropertyValue( "Endpoint",  "EndPoint" + "/xml")

     

    Output Request URL:   http://${#Project#Endpoint}/xml