cucumber-api icon indicating copy to clipboard operation
cucumber-api copied to clipboard

How to do a PUT/POST with content type as text/plain?

Open sandeepnagra opened this issue 8 years ago • 2 comments

I tried something like:

Scenario: Try to set keep data value under database settings with response code 200 Given I send "text/plain" and accept JSON When I send a PUT request to "http://hostname:8080/settings/databaseSettings/dataRetention" with: | 90 | Then the response status should be "200"

But it fails. I have always used JSON request body, this is the first REST API which needs plain text and I am trying to figure out how to do it.

sandeepnagra avatar Jun 30 '17 21:06 sandeepnagra

Temporarily, I have created following custom step:

When(/^I set request body to "(.*?)"$/) do |value| @body = value end

and then the following scenario works:

Scenario: Try to set keep data value under database settings with response code 200 Given I send "text/plain" and accept JSON And I set request body to "90" When I send a PUT request to "http://hostname:8080/settings/databaseSettings/dataRetention" Then the response status should be "200"

sandeepnagra avatar Jun 30 '17 22:06 sandeepnagra

That would be my approach for this as well. Make a PR, probably adding a sample and I'll merge it!

hidroh avatar Jul 02 '17 10:07 hidroh