extractFromPayload

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

extractFromPayload

hlopez
How do I extract a value from payload using java DSL?

In the documentation here you only mentioned the xml way.
http://www.citrusframework.org/reference/html/index.html#ignore-with-jsonpath

I'm trying the following way:

        String receivedId= "0";

        receive(builder -> builder.endpoint(httpClient)
                .header(HTTP_STATUS_CODE, HttpStatus.OK)
                .header(HTTP_CONTENT_TYPE, MediaType.APPLICATION_JSON_UTF8_VALUE)
                .messageType(MessageType.JSON)
                .extractFromPayload("$.id", receivedId)
                .payload(person1, objectMapper)
                .ignore("$.id")
                .build()
        );
        System.out.println("****** Received id: " + receivedId + " for person1.");

That prints out: ****** Received id: 0 for person1.

So it's not getting the id out to my variable. Maybe it is extracting it into a CitrusVariable, how do I get the value of the variable out of Citrus back to my program?

Humphrey
Reply | Threaded
Open this post in threaded view
|

Re: extractFromPayload

hlopez