Feature: testing e2e scenario of Gorest API's Background: * url 'https://gorest.co.in/public/v2/users'
Scenario: get all user details in gorest Given path '331868' And headers Authorization = tokenID #getting tokenID from config file When method GET Then status 200 * print response * def Getresponse = response * match $.name == Getresponse.name * match $.gender == Getresponse.gender
Given request """ { "name": "Bhuvana Teja", "email": "[email protected]", "gender": "male", "status": "active" } """ And headers Authorization = 'Bearer 1c5b1bef45c28336e41debe1e910f1bb5c905af8c9d1181c92ad62566b724d68' When method POST Then status 201 * print response * def PostRes = response * match $.id == PostRes.id
Sorry I don't have much knowledge of Karate script, below is the equivalent of curl post example given in the homepage
Given url 'https://gorest.co.in/public/v2/users'
And header Accept = 'application/json'
And header Content-Type = 'application/json'
And header Authorization = 'Bearer xxxxxxxxxxxxxxxxx'
And request '{"name":"Tenali Ramakrishna", "gender":"male", "email":"tenali.ramakri[email protected]", "status":"active"}'
When method post
Then status 200