mockserver: Error in deserialization of JSON

i’m trying to send application/x-www-form-urlencoded request with body to:email@email.com

this is the test code: new MockServerClient("localhost", 1080) .when(request("/messages") .withMethod("POST") .withQueryStringParameter(Parameter.param("to","email@email.com")) ) .respond(response().withStatusCode(200)); And when this code is executed, i have this exception: IllegalArgumentException: Exception while parsing [{ "httpRequest" : { "method" : "POST", "path" : "/messages", "queryStringParameters" : { "to" : [ "email@email.com" ] } }, "httpResponse" : { "statusCode" : 200 }, "times" : { "remainingTimes" : 0, "unlimited" : true }, "timeToLive" : { "unlimited" : true } }] for Expectation

com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize instance of java.lang.String out of FIELD_NAME token at [Source: (String)"{ "httpRequest" : { "method" : "POST", "path" : "/messages", "queryStringParameters" : { "to" : [ "email@email.com" ] } }, "httpResponse" : { "statusCode" : 200 }, "times" : { "remainingTimes" : 0, "unlimited" : true }, "timeToLive" : { "unlimited" : true } }"

How can i bypass or fix this?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 3
  • Comments: 17

Commits related to this issue

Most upvoted comments

I used version 5.1.1 and it worked.

        <dependency>
            <groupId>org.mock-server</groupId>
            <artifactId>mockserver-netty</artifactId>
            <version>5.1.1</version>
        </dependency>
        <dependency>
            <groupId>org.mock-server</groupId>
            <artifactId>mockserver-client-java</artifactId>
            <version>5.1.1</version>
        </dependency>

Hi @IgorMaksymov ,

To what I have seen at the moment, it seems that the problem is for the com.fasterxml.jackson.core:jackson-databind:2.9.4 library.

For the moment to bypass the error I have forced the use of the com.fasterxml.jackson.core:jackson-databind:2.9.3 library.

@CarlosLoboZamarro thanks! In your explanation conflict and fix versions are the same. @jamesdbloom could you fix this issue? Because spring boot 2 provides this jackson dependency and its not good to exclude it from parent