Unable to pass string value in post request variable value

Good Day,

Given
1.I’m able to print CPTCodeId in my method “clickSaveAddCPTActive” *See below

image

  1. WS.sendRequest is working if I set manually the variable and running manually the post request *See below

HTTP Body

query CPTCode{
  cptCodes(filter: {patternMatch: EXACT, code: "${code}"}) {
    code
    description
    validityStartDate
    validityEndDate
  }
}

Variable in WS

Result

Problem

  • Now When Im running my testcase specially for this method which I’m trying to parameterizing the default value of variable “code” in WS
    I’m getting the error below in console and I’m not able to set the value of variable “CPTCodeId” to the WS variable default value


{"errors":[{"message":"Query variables must be a null or an object."}],"extensions":{"tracing":{"version":1,"startTime":"2022-08-31T16:37:38.699834Z","endTime":"2022-08-31T16:37:38.700100Z","duration":263718,"execution":{"resolvers":[]}}}}

Here’s my script

Expectation
Whatever the value of variable CPTCodeId should be pass to the variable code in WS dynamically

Help will be appreciated thanks!

1 Like

Found a solution:

I updated my script on this part
ResponseObject res = WS.sendRequest(findTestObject('CPT/CPT_GraphQL',['code': CPTCodeId]))

for Variable in WS:

Http Body

Result