Not able to create new stub from java where as same works from postman

35 views
Skip to first unread message

shogv48

unread,
Mar 17, 2021, 11:19:53 AM3/17/21
to wiremock-user
Hi ,
I am trying to create stub through java code but fails with http 422 error, where as when I try same from postman getting success 201 created.

        String mapping =
                "{" //@formatter:off
                + "\"priority\": 1,"
                + "\"request\": {"              
                + "\"urlPath\": \"/api/v1/organizations/685110093313737070/admins\","
                + "\"method\": \"GET\""
                + "},"
                + "\"response\": {"
                + "\"status\": 200,"
                + "\"jsonBody\": {"
                + "\"id\": \"85110093313760778\","
                + "\"name\": \"name\","
                + "\"email\": \"na...@mail.com\""
                + "}"; // @formatter:on

        addMappingToStub(mapping);

    }

    private static void addMappingToStub(String mapping) {

        RestAssured.given()
                .header("Content-Type", "application/json")
                .body(mapping)
                .post(http://localhost:8080/__admin/mappings")
                .then()
                .assertThat()
                .statusCode(HttpStatus.SC_CREATED);
    }

Postman: URL:  http://localhost:8080/__admin/mappings
{   "priority": 1,
    "request": {
        "method": "GET",
        "url": "/api/v1/organizations/685110093313737070/admins"
    },
    "response": {
        "status": 200,
        "jsonBody": {
            "id": "85110093313760778",
            "name": "name",
            "email": "na...@mail.com"
        }
        
    }
}

shogv48

unread,
Mar 17, 2021, 2:45:46 PM3/17/21
to wiremock-user
getting belwo error  from java code
<html>
  <body>com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve type id 'priority' as a subtype of [simple type, class com.hp.ov.activator.ci.dde.openstack.itf.CreateServiceRequest]: known type ids = [service]
 at [Source: (io.undertow.servlet.spec.ServletInputStreamImpl); line: 1, column: 2]</body>
</html>


Reply all
Reply to author
Forward
0 new messages