1

I'm new to writing feature files. I'm trying to test POST call with json body, but the result says invalid request. I'm trying to send Json array in the body, definitely missing something in the body. Below are the json body and what I wrote for feature file. Is there is another way to give the request body as a file from a folder.

{
 "paymentDetails": 
 [
  {
  "aaaaaa": "AAAAAAAAAA",
  "bbbbbb": "BBBBBBBBBB",
  "cccccc": "CCCCCCCCCC",
  "dddddd": {
    "ddddddd1": {
      "dddddd1.2": {
        "addressLine1": "abc ST",
        "city": "BROOKLYN",
        "state": "NY",
        "zip": "123123",
        "USAddress": true
      }
    }
  },
  "eeeeeee": "EEEEEEEE",
  "fffffff": "FFFFFFFF",
  "ggggggg": 29,
  "hhhhhhh": {
    "hhhhhh1": "NY",
    "hhhhhh2": "10"
  },
  "iiiiiiii": true,
  "jjjjjjjj": "123",
  "kkkkkkkk": "3481",
  "llllllll": 0
 }
]
}

Scenario: POST Rest endpoint
Given a user with username "xxxxxx"
And a password of "zzzzzzzzzzzzzzz"
And a body with "aaaaaa" as "AAAAAAAAAA"
And a body with "bbbbbb" as "BBBBBBBBBB"
And a body with "cccccc" as "CCCCCCCCCC"
And a body with "dddddd.ddddddd1.dddddd1.2.addressLine1" as "abc ST"
And a body with "dddddd.ddddddd1.dddddd1.2.city" as "BROOKLYN"
And a body with "dddddd.ddddddd1.dddddd1.2.state" as "NY"
And a body with "dddddd.ddddddd1.dddddd1.2.zip" as 123123
And a body with "dddddd.ddddddd1.dddddd1.2.USAddress" as "true"
And a body with "eeeeeee" as "EEEEEEEE"
And a body with "fffffff" as "FFFFFFFF"
And a body with "ggggggg" as 29
And a body with "hhhhhhh.hhhhhh1" as "NY"
And a body with "hhhhhhh.hhhhhh2" as 10
And a body with "iiiiiiii" as "true"
And a body with "jjjjjjjj" as 123
And a body with "kkkkkkkk" as 3481
And a body with "llllllll" as 0
When a POST request is made to "https://..............."
Then log response body
And response code is 200 
Lucky
  • 783
  • 2
  • 10
  • 28

1 Answers1

0

To make sure you are sending correct json messages, you might consider creating domain objects and serializing them to json using a library like jackson.

In addition, you could use a builder pattern to fill the necessary fields on your object.

There are plenty of tutorials out there to show you how this would work.

Marit
  • 2,399
  • 18
  • 27