Miguel Sanchez
Miguel Sanchez

Reputation: 37

Question about Karate test case for POST method

I have an endpoint URL, within Swagger I must pass certain fields to test the POST method. I was wondering if anyone had an example of how to set up a Karate test for a POST method?

Upvotes: 1

Views: 270

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58088

Yes, there are plenty in the documentation: https://github.com/intuit/karate

If you follow the quickstart, you will get a sample project with a working POST: https://github.com/intuit/karate#quickstart

Scenario: create a user and then get it by id

* def user =
"""
{
    "name": "Test User",
    "username": "testuser",
    "email": "[email protected]",
    "address": {
      "street": "Has No Name",
      "suite": "Apt. 123",
      "city": "Electri",
      "zipcode": "54321-6789"
    }
}
"""

Given url 'https://jsonplaceholder.typicode.com/users'
And request user
When method post
Then status 201

Upvotes: 1

Related Questions