Reputation: 63
Here is my JSON request example code and as u can see #(Paramtervale) as to be replaced by MyValue
Below is the example of the request json and code:
* request
"""
{
"query": {
"bool": {
"must": [
{
"match_data": {
"Event.Data.message": "#(Paramtervale)"
}
},
{
"match_data": {
"Event.Name": "#(Paramtervale2)"
}
}
],
"filter": {
"range": {
"@timestamp": {
"gte": "now-1m"
}
}
}
}
}
}
"""
* set request.Event.Data.message = myvalue
* set request.{Event.Data.message} = myvalue
* set request.(Event.Data.message) = myvalue
None of the above is working, can anyone please help
Upvotes: 4
Views: 1225
Reputation: 1096
Sample Code:
Feature: Validation
Scenario:
* def req =
"""
{
"query": {
"bool": {
"must": [
{
"match_data": {
"Event.Data.message": "#(Paramtervale)"
}
},
{
"match_data": {
"Event.Name": "#(Paramtervale2)"
}
}
],
"filter": {
"range": {
"@timestamp": {
"gte": "now-1m"
}
}
}
}
}
}
"""
* req.query.bool.must[0].match_data["Event.Data.message"] = "abc"
* req.query.bool.must[1].match_data["Event.Name"] = "def"
* print req
Upvotes: 0
Reputation: 58058
Here are 2 different ways, note that for updating a JSON, set
is not needed any more. When special characters are in key names, use the square-bracket approach to refer to JSON data:
* def temp = { 'a.b': 'xxx' }
* temp['a.b'] = 'yyy'
* match temp == { 'a.b': 'yyy' }
# using embedded expressions
* def val = 'yyy'
* def temp = { 'a.b': '#(val)' }
* match temp == { 'a.b': 'yyy' }
Upvotes: 4