In the previous blog, we saw how to make GET and POST calls using karate DSL. In this blog, we will see how we can use karate DSL by reading data from external files and also how we can change the values of the request body.
{
"firstName":"James",
"lastName":"White",
"username":"jamesWhite",
"email":"james@user.com"
}
And def BodyOfRequest = read('/home/ankur/Desktop/KARATE/new/karateBlog/src/test/java/examples/users/dataFiles/userData.json')
And request BodyOfRequest
Feature: POST API call.
Background:
* url 'https://43db3005-4ed9-4bab-b0a3-bb066e79e816.mock.pstmn.io'
Scenario: create a user from given details.
Given path '/POSTUser'
And def BodyOfRequest = read('/home/ankur/Desktop/KARATE/new/karateBlog/src/test/java/examples/users/dataFiles/userData.json')
And request BodyOfRequest
When method post
Then status 201
And match $.Status == '#present'
And match $.Status == 'OK'
#scala #dsl #karate dsl #data