Appending a query parameter to request URL of a node script target

We're currently adding a query parameters for several target endpoints by building target.url from target.url + proxy.pathsuffix + request.querystring + {additional_parameters} in each target preflow.

We're now trying to achieve the same effect with a target that is a node app, but this approach doesn't work. Are we able to manipulate the target path or will we need to modify the node app to achieve this?

0 3 3,683
3 REPLIES 3

Hi @Jon Kneller,

I don't see a way to do what I think you're asking that's documented -- i.e., changing or manipulating the ResourceURL for the ScriptTarget the way you can manipulate the target.url for HTTPTargetConnections. I think you'll have to handle request query or path parameters in your Node app. Or, you can pass arguments from the proxy to the Node app, as explained here. Here's an example from the StreetCarts sample, where the Node app handles different URI paths. Hope this helps or, if anyone else has a suggestion, please follow up.

Will

Hi @Jon Kneller You should be able to append the query parameters with an AssignMessage policy or a JavaScript policy on the target pre-flow. It should not matter whether you are using an actual Target or a node.js script within Apigee. I just tried it myself on a simple HelloWorld node.js proxy (attached) and it seems to be working. As you can see I am appending a Queyr Param with an AssignMessage policy and printing that in the node.js target. helloworld-rev1-2016-05-25.zip Did I miss anything?

Thanks for the responses. Unfortunately we're working with an API that currently requires duplicate keys in the query params, so using the AssignMessage policy wasn't an option.

For the time being we're setting a variable and accessing that from Node; in the future I hope we can remove the need for duplicate keys and move to an AssignMessage policy in Apigee.

Thanks again

Jon