Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

REST API URL in Extension Tool

tapan1986
tapan1986 Posts: 27

How to get the REST API URL in the extension tool ?

Tagged:

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,302 ✭✭✭

    URL for what REST API? Where is the URL you are trying to get? In an environment variable?

  • tapan1986
    tapan1986 Posts: 27

    the current URL I am hitting(in the request). I have to pass that to extension tool for validations of pagination.The URL is created taking host variables from environment and data from Data source.

  • benken_parasoft
    benken_parasoft Posts: 1,302 ✭✭✭
    edited February 2019

    As one possible option for you, you could chain an Extension Tool to your client's "Traffic Object" output then use a Groovy script like this:

    import com.parasoft.api.*
    
    void test(Map input, ScriptingContext context) {
        Application.showMessage(input.get("End Point"))
    }
    

    Otherwise, that ScriptingContext object passed to the script also has "getEnvironmentVariableValue" and "getValue" methods you can call to resolve environment variables and data source columns, in case you want to make your script build the same URL from variables and/or data source or data bank columns. Something like:

    context.getEnvironmentVariableValue("BASEURL") + context.getEnvironmentVariableValue("PATH") + context.getValue("Generated Data Source", "column name")
    

Tagged