Learningbear
4 years agoRegular Visitor
Ready API, groovy script, how to pass a variable as an input of a field for Mongo DB document
I have a mongo DB collection with document structure as below
{
_id : ObjectId("5e66a38b478d946943329bba"),
name : "Tom",
age : 26, '
ID : "SD34re",
Gender : "Male"
}
I'm using groovy script in Ready API to make Mongo DB connection and fetch above document.
Now, I need to pass a dynamic value from variable "SSN" to ID value above. How can I do it using groovy script in Ready API.
Ex: def SSN = context.expand('${#TestCase#SSN}')
SSN value to be passed as below in document using groovy script in ReadyAPI. How can I achieve it?
{
_id : ObjectId("5e66a38b478d946943329bba"),
name : "Tom",
age : 26,
ID : SSN,
Gender : "Male"
}