Possible to assign ScriptOutput in Execution phase to a variable?

Not applicable

I need to assign the entire output from the execution of the target (js) script to a variable (so that I can ship it via syslog). The ScriptOutput property has all the info I need, which exists during the execution phase, and then seems to disappear. I'm trying to use AssignVariable, and have successfully captures other variables that come in and out of scope.

I've tried at both target pre and post flow. I can't figure out if there is a place where I can assign this to a variable while it's in scope, or maybe the issue is that it's never actually in scope?

Or maybe the issue is that this is a "property" and not a variable? If so, is there a way to capture properties?

0 4 127
4 REPLIES 4

Try in proxy post flow..Just attach js to fetch the target response..

example JS would look like below & logging.Respmessage has the response from target which you can use to in MessageLogging

var logMessage = context.getVariable("response.content");
context.setVariable("logging.Respmessage","###### RESPONSE ###### : " + logMessage);

fyi..

https://docs.apigee.com/api-platform/fundamentals/what-are-flows

The script output is not the response content. Script output is the output of a target script (for instance, what gets logged to console), whereas response.content is the contents of the HTTP response from the target endpoint. These are completely different things.

what do you mean by "output of a target script"? What kind of target script? Can you be specific?

Is it a nodejs script? Used as a target? running in Trireme?

IF so, you can write to context variables with the apigee-access rpm module.

The target for this api is a nodejs script, which then invokes aws lambdas. I'm referring to a specific property called ScriptOutput. If you click on the first circle after the target (but before TargetResponseFlow), called "Response received from target server", there is a list of Properties there: [Expression, ExpressionResult, Tree, action, enforcement, internal, result, ScriptName, ScriptOutput, ScriptType, type]. These are distinct from variables, response headers and response content.

I can't use apigee-access in this script because it gets variables as part of a request - I need some variables from this script related to the duration of certain functions, they are not part of any request, so I can't use apigee-access or put them in the response header/payload. Another long story short, I also can't scrape them from the cached nodejs log endpoint due to logstash not being able to tell which logs are "new".

So I'm trying to figure out if I can get it from the ScriptOutput property, in the same way I can use AssignMessage to grab other variables.