cancel
Showing results for 
Search instead for 
Did you mean: 

API Management: target.url and target.host is null in JavaScript in TargetEndpoint Preflow Policy

WRoeckelein
Active Participant

Hi All,

I need to do an additional request to the backend before the original request.

So I have in the Policy in the TargetEndpoint Preflow a JavaScript call.

But I can't access the host I need for the url in "new Request(url, 'GET', headers)".

Both target.url and target.host are null, target.host is only filled in the PostFlow.

Eg the example JS File https://github.com/SAP/cloud-api-management-samples/blob/master/authentication/saml/APIProxy/FileRes... uses context.getVariable("target.url") which always null in my tests. so this will also not work.

Any idea how to solve this problem?

Thanks,

Wolfgang

Accepted Solutions (0)

Answers (1)

Answers (1)

arjanboer
Discoverer
0 Kudos

Hi Wolfgang, Community,

I have the same challenge. I want to manipulate the destination/target URL. When a request URL: path/ZMY_ENTITY/{key} comes in I want to remove the {key} part from the URL and map it to a query parameter. Following the Apigee methods you need to adjust the target.url in the TargetEndPoint Preflow. Unfortunately this variable is empty in SAP API management during the Preflow event.

Did you solve this issue? Or how can it be solved?

WRoeckelein
Active Participant
0 Kudos

Hi arjanboer ,

sorry for the late reponse. Caveat: I can only talk about reading, not about modifying stuff from target URL.

Eg target.basepath, context.targetRequest.uri and context.targetRequest.url is available in the target preflow.

For target.host after some discussion with SAP support we use the fixed string opproxyapimgmtpr-XXXXX.hana.ondemand.com where XXXXX is the technical subaccount name (on NEO, I don't have experience with API Management on CF).

Regards,

Wolfgang