my requests is created using csv file I need to modify/delete few values in a json request, I have a function that should make Modify/Delete the Key Values
however the delete obj[key]
generates error
Feature: Validate TCs
Background:
Given url 'https://'+env_apiHost
Given path '/abc/pqr-stu/v1/wxy-zzzz'
Scenario Outline: Validate Functional Data
* def CHK_NULL = 'CHK_NULL'
* def CHK_MAND = 'CHK_MAND'
* def modify_pop_key =
"""
function(obj) {
for(var key in obj) {
if (typeof obj[key] === 'object') {
modify_pop_key(obj[key])
}else if (obj[key] === CHK_MAND) {
delete obj[key]
}else if (obj[key] === CHK_NULL) {
obj[key] = ''
}
}
}
"""
* def request_string =
"""
{
"Key1": "<key1>",
"key2": "<key2>",
"key3": "<key3>",
"key4": "<key4>"
}
"""
* def req1 = call modify_pop_key request_string
And request request_string
When method post
Then status 200
* print response
Examples:
read('classpath:data/jsnVals.csv')|
data/jsnVals.csv
| key1 | key2 | key3 | key4 |
| HAPPY | Val_12 | Val_13 | Val_14 |
| TC_001 |CHK_MAND| Val_23 | Val_24 |
| TC_002 |CHK_NULL| Val_33 | Val_34 |
| TC_003 | Val_42 | Val_43 | Val_44 |
Error:
* def req1 = call modify_pop_key request_string
org.graalvm.polyglot.PolyglotException
src/test/java/xxxxx/feature/pqr_xyx.feature:58