
Send Headers and Cookies in REST Assured
Send headers one by one, from a map and as objects, learn which headers are merged and which are overwritten, see the charset REST Assured adds to text content types, and send cookies.

Send headers one by one, from a map and as objects, learn which headers are merged and which are overwritten, see the charset REST Assured adds to text content types, and send cookies.

Send a JSON body as a String, a Map, a Java record or a List, send bytes and files as they are, and test the API's answer to an invalid body (422) and the wrong content type (415).

Read, replace, patch and cancel a payment, get headers with HEAD, discover methods with OPTIONS, search with the new QUERY method, send any method by name, and test a 405.

Upload a CSV file with a text field as multipart/form-data, from a File, from bytes with a file name and with MultiPartSpecBuilder, and test a request with a missing part.

Filter and transform JSON lists with Groovy closures, covering find, findAll, collect, any and every, max and min, indexes and ranges, flattening, keys with dashes and a JSON array at the root.

Stop repeating the start of every path with rootPath, move it with appendRootPath, detachRootPath and noRootPath, and reuse one path for different values with withArgs.

Learn how REST Assured reads JSON numbers, why the default Float can't hold money, how to read decimals as BigDecimal with JsonConfig, why comparesEqualTo beats equalTo, and when closeTo is the right choice.

Pick the right Hamcrest matcher for each check, covering hasItems, contains and containsInAnyOrder, everyItem and empty, hasKey and hasEntry, string matchers, and combining matchers with allOf, anyOf, oneOf and not.

Check values the server chooses by building the expectation from the response, covering a Location header that must end with the new id, endsWithPath(..), one body value checked against another, and a matcher on the whole body.

Check the cookies a server sets, from their values to the security attributes of a session cookie (Secure, HttpOnly, SameSite, Path and Max-Age) with detailedCookie(), and read a Cookie object afterwards.