Request mandatory for POST method call in Karate

Viewed 1942

Today I came across a scenario where there was a POST method call but that does not require a request data and query parameters are sufficient. But in Karate framework it is mandatory to give request data when it is POST method. So I had to provide request as 'null' explicitly. Is there any way in Karate that if there is no request data then you can skip providing request data as 'null'.

2 Answers

This is what I usually do if there's no request body :

Given path '/path/to//action'
And request ''
When method post
Then status 200

(Haven't found a way to skip the request step)

I tried this way:

Given url 'url'
And params param_value
And request '{}'
When method post
Then status 200

Its same as mentioned above just I gave empty request body

Related