Groovy REST Request - Scripted Input

GambitGambit Posts: 15

When creating a REST request, I have three options for the data I send 1) Fixed, 2) Parameterized, and 3) Script

I am attempting to use the script option to create a groovy script that will generate a random number each time I run a test. This is the script I have so far and I'm seeing the error "Argument count should be 0 or 1 instead of 2". Can someone help?

import com.parasoft.api.*
import java.util.*
import org.apache.commons.lang.RandomStringUtils

def setup(input, context){
Random random = new Random()
x = UUID.randomUUID().toString()
return x
}

Comments

  • jakubiakjakubiak Posts: 527 admin

    In the dialog that pops up there is a link that says "Expected number of arguments: 0 or 1". When you click the link, you get a message that tells you that the script expects 0 or 1 arguments, and if you do include the 1 argument that it is of type ScriptingContext. So in your case you need to modify your script and simply remove the "input" parameter. You also can optionally remove the "context" parameter as well since your script doesn't use it.

  • GambitGambit Posts: 15

    That was the problem! I was going in circles trying to figure out why this exact script works outside of this particular menu, but not embedded.

Sign In or Register to comment.