4

I am getting below error when I am trying hit a endpoint url with post method which does not have a body. In postman I am able to hit endpoint url with post method without body. I tried all steps by referring the Karate API docs.

 **Error** : com.intuit.karate.exception.KarateException: TestScenarios.feature:56 - 
request  body is required for a POST, please use the 'request' keyword

testurl is :

 **test-api.test.com/test-com/api/check/initiate? 
lang=en&cntCode=us&id=8d1b9355**

Attempt 1:

Given url 'test-api.test.com/test-com/api/check/initiate?lang=en&cntCode=us&id=8d1b9355'
When method post
Then status 200
* print  response

Attempt 2:

Given url testurl
And param lang= en
And param cCode = us
And param id= '8d1b9355'
When method post
* print 'Response'+response

Attempt 3:

Given url testurl
And form field lang= en
And form field cCode = us
When method post
Then status 200

Can someone help me to understand the issue and wrong in my approach.

sam
  • 289
  • 7
  • 19
  • 3
    Yeah... at last i found the solution by my self. I should be be passing request body as empty like And request {}. Earlier I tried empty request but with () parenthesis not with {} – sam Mar 13 '19 at 00:34
  • have answered anyway to help others in future – Peter Thomas Mar 13 '19 at 03:51

1 Answers1

4

Two possible options depending on your server:

* request {}

Or as per the docs:

* request ''
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248