Chamly Idunil
Chamly Idunil

Reputation: 1872

Apigee Wildcard Proxy forward for invalid target

I Have Apigee Proxy with base path as /api/*/names to support /api/v1/names and /api/v2/names

Proxy Target Server configuration is

<HTTPTargetConnection>
    <LoadBalancer>
      <Server name="mockable-demo3383377"/>
    </LoadBalancer>
    <Path>{proxy.basepath}</Path>
  </HTTPTargetConnection>

You can try to target endpoints with the below URLs

The issue is when I request through apigee as /api/v1/names or /api/v2/names its forward the request to mockable as /api/*/names.

The error response from mockable

<h2>Mock not found!</h2>
        <dl>
            <dt>Space</dt>
            <dd>demo3383377</dd>
            <dt>Method</dt>
            <dd>GET</dd>
            <dt>Path</dt>
            <dd>api/*/names</dd>
            <dt>Content-Type</dt>
            <dd></dd>
            <dt>Accept</dt>
            <dd>*/*</dd>
            <dt>SoapAction</dt>
            <dd>None</dd>
        </dl>

I tried with AssignMessage policy

<AssignMessage name="AdjustPath">
  <Set>
    <!-- Combine proxy.basepath and proxy.pathsuffix -->
    <Path>{proxy.basepath}{proxy.pathsuffix}</Path>
  </Set>
</AssignMessage>

and JavaScript Policy as

var proxyBasePath = context.getVariable("proxy.basepath"); // This will give /api/*
var pathSuffix = context.getVariable("proxy.pathsuffix");  // This will give the rest of the path like /v1/names

// Combine them to get the full actual path
var actualBasePath = proxyBasePath.replace("*", "") + pathSuffix;
context.setVariable("actualBasePath", actualBasePath);

nothing work.

Appreciate any help.

Thanks

Upvotes: 0

Views: 35

Answers (0)

Related Questions