JavaCallout Request Message is empty

We´ve been using javaCallouts for checking the content of requests, but since the latest update (Private EdgeCloud 4.19.01) we can not access this information.

Based on the example from here: https://github.com/apigee/api-platform-samples/blob/master/doc-samples/java-cookbook/callout/src/mai...

You can read the content and analyse it:

String content = messageContext.getMessage().getContent();

Or use a InputReader for longer Body:

messageContext.getRequestMessage().getContentAsStream()

My question is, does any body knows why this messageContext no longer allows access to the Payload?

Is there any other way for reading the Payload in Java?

Every Request returns empty content.

Thank you very much

Solved Solved
1 4 591
1 ACCEPTED SOLUTION

"we can not access this information"

What do you mean? It always returns an empty string?

That is surprising and sounds like a bug to me. But maybe it is because there is streaming enabled on the API? If not that, then please raise a bug with Apigee Edge support.

Have you tried

messageContext.getVariable("request.content") ;

?

View solution in original post

4 REPLIES 4

"we can not access this information"

What do you mean? It always returns an empty string?

That is surprising and sounds like a bug to me. But maybe it is because there is streaming enabled on the API? If not that, then please raise a bug with Apigee Edge support.

Have you tried

messageContext.getVariable("request.content") ;

?

Thank you very much.

That was exactly the point. We added request and response streaming and therefore both the getVariable and the requestMessage method are not able to obtain any information from the Request.

Do you know if there is any option to access the body content without deactivating streaming?

It would be a nice way to improve performance in our proxies.

Thanks in advance

No, if you enable streaming, then the policies like JS calluot and Java Callout cannot access the message payload. When streaming is enabled, the message payload is never de-serialized and made available to any policy, including but not limited JavaScript and Java.

Streaming allows an optimization, but that is the tradeoff: you can neither read nor modify the message payload within the request and response flow.

Thank you for the Info.

Have a nice day