I'm making endpoint call from within java callout and trying to set the responset in my callout. I get a NullPointerException when I access MessageContext.getResponseMessage().setContent(mycontent). According to docurmentation (http://docs.apigee.com/api-services/reference/variables-reference), this variable is not in scope until Target response. Since I do not have a target, how can I set this variable?
Version 4.16.09.02
Solved! Go to Solution.
It's likely that the Java callout is running in the request flow.
In this case there is no Response Message, and so getResponseMessage() is returning null.
You are then de-referencing that null pointer, resulting in the NPE.
possible Solutions or avoidances (choose one)
The second approach is probably preferred because it makes your java callout more resilient in general.