Kumar
Kumar

Reputation: 41

Rest assured api automation- posting big json payload with few parameters or dynamic data

Rest assured api automation-how to post big json payload in body with few parameters or dynamic data .

xxxx is the data need to be passed dynamically with every post request. It can be from csv file or some random data.

{
Id:xxxx
Name:test123
City:Edison 
Profile :{
        Startdate: xxxx
        Enddate:xxxx
        Product: abcd 
         }
Renewal: {
         Auto renewal: yes
         Term: 1 year
         }

}

Upvotes: 0

Views: 2195

Answers (1)

lucas-nguyen-17
lucas-nguyen-17

Reputation: 5917

Rest-Assured supports many ways to deal with json payload

  • String: not good for this situation
  • Map: for simple and not too much key-value pair
  • POJPO: the main option here

For your case, I would recommend the POJO approach.

  1. you create a Java object to map with Json object,
  2. then use one of the Serialize/Deserialize libraries (jackson, gson) to convert Java object to Json object.
  3. Rest-assured will automatically do converting for you, you just declare the lib in classpath

More infomation here: https://github.com/rest-assured/rest-assured/wiki/Usage#serialization


For the part: It can be from csv file or some random data. --> it can be easily achieved by supporting from Test framework (Junit5 or TestNG)

Upvotes: 0

Related Questions