1

I would like to pass the JSON array to the another feature file as an argument and I am using the below steps: Below is the json array, I have to pass

[
  {
    "attr1": 14,
    "attr2": 1
  }
]

The Code I have written is:

      * def requestPayload = read('classpath:api/data/request/deliveryrank/sample.json')
      * def addProjects = call read('classpath:api/features/common/example.feature') requestPayload

I tried using the method explained in "https://stackoverflow.com/questions/68986777/passing-a-json-array-while-calling-another-feature-file" but the request is send like

* def array = [{"attr1": 14,"attr2": 1}]
* def arg = { data: '#(array)' }
* call read('classpath:com/example/Test.feature') arg

Request in call:

{"data":[{"attr1":14,"attr2":1}]}

but it should go as it is [{"attr1": 14,"attr2": 1}]

2
  • I pass as this is incomplete and too complicated to understand. Commented Aug 2, 2022 at 14:30
  • It is now working, I was not referring to it properly. In Test.feature I am now referring it as arg.data to get the array directly. Thanks @PeterThomas. Commented Aug 3, 2022 at 3:06

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.