Skip to content
Advertisement

I’m receiving an java.lang.AssertionError in a test using REST Assured

This is the first time for me using Gson and REST Assured, and I am really struggling to be honest. I need to verify that the content type is JSON and it is, but the test fails with the following message that you will see below. I am not writing all the imports that I have, if it is needed please tell me and I will provide them.

This is the code that I have written:

JavaScript

And this is the response I get:

JavaScript

How can I fix this?

Advertisement

Answer

The problem is Rest-Assured automatically add charset=utf-8, that may be returned back in response.

You can assert them as follow:

JavaScript

or to disable automatic charset=utf-8 in request header:

JavaScript
Advertisement