Skip to content
Advertisement

Rest Assured – can’t POST with Parameters and Body

I’m testing a REST api using Rest Assured. I’m running into an error when trying to POST with both a parameter in the url and body content. This works correctly when testing manually. Removing the parameter form the url is not an option

Test Code:

JavaScript

Which throws the following error when run

JavaScript

Why does Rest Assured not allow both parameters and body content in a POST?

Advertisement

Answer

You need to specify the parameter as queryParameter and not “param” or “parameter”. Param for POST will default to form parameters which are sent in the request body.

I.e.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement