how to use service callout policy in apigee

hi folks

I have a simple API proxy named mock and the backend is associated with mock-target and uses some critical API token in this proxy 

so now I want to expose this proxy but there we can see all the policy attach to my proxy in trace section so I want to hide this 

and want only a single proxy with no policy 

means want to use proxy chaining but not using proxy chaining concept using service callout policy

thanks for any guidance or suggestion.

 

Solved Solved
0 11 2,214
1 ACCEPTED SOLUTION

@rohanjangid - I see you dont want to use Proxy chaining, so you want to give the full URL in the Service Callout policy. The policy will look something like this

 

<ServiceCallout name="ServiceCallout-Proxy1">
    <DisplayName>ServiceCallout-Proxy1</DisplayName>
    <Request variable="proxyRequest" />
    <Response>proxyResponse</Response>
    <Timeout>30000</Timeout>
    <HTTPTargetConnection>
      <URL>http://api-acme.com/v1/foo</URL>
    </HTTPTargetConnection>
</ServiceCallout>

View solution in original post

11 REPLIES 11

@rohanjangid - your question is not clear. Can you be more precise on what you want? Not sure if you want a pass-thru proxy or if you want one proxy to call another without proxy chaining? Proxy chaining is the recommended approach if you are calling one proxy from another.

Will be able to provide more guidance if you can be more clear on the ask

@ssvaidyanathan thanks for replying i want to call one proxy to another proxy but without using proxy chaining using service call out policy

first proxy = having mock backend and some policy attached

second proxy = (no target) = will call first proxy using service callout policy

Ok - so you want the 2nd proxy to call the first proxy? 

If you just want to call it, just set the URL of the first proxy as the target URL in 2nd proxy

For example - Proxy 1 is https://api-acme.com/v1/foo

Then use this URL as the target URL in your 2nd proxy

@ssvaidyanathan we can do so i want to use service callout policy here in second proxy

@rohanjangid - you have got me confused again. You said "without" service callout and now you want it with service callout. Please be precise

Proxy 1 --> Proxy 2 and you want the call from Proxy 1 to Proxy 2 go via Service callout? 

@rohanjangid - I see you dont want to use Proxy chaining, so you want to give the full URL in the Service Callout policy. The policy will look something like this

 

<ServiceCallout name="ServiceCallout-Proxy1">
    <DisplayName>ServiceCallout-Proxy1</DisplayName>
    <Request variable="proxyRequest" />
    <Response>proxyResponse</Response>
    <Timeout>30000</Timeout>
    <HTTPTargetConnection>
      <URL>http://api-acme.com/v1/foo</URL>
    </HTTPTargetConnection>
</ServiceCallout>

@ssvaidyanathan i did as suggested by you create a service callout policy in preflow

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ServiceCallout async="false" continueOnError="false" enabled="true" name="Service-Callout-2">
    <DisplayName>Service Callout-2</DisplayName>
    <Properties/>
    <Request clearPayload="true" variable="myRequest">
        <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    </Request>
    <Response>mock-servicecallout</Response>
    <HTTPTargetConnection>
        <Properties/>
        <URL>https://rohanjangid-eval-test.apigee.net/mock-servicecallout</URL>
    </HTTPTargetConnection>
</ServiceCallout>

but as soon as  hit this I got a response a white screen with status code 200

@rohanjangid - thats because the response variable you used is "mock-servicecallout". If you want the response of the service callout to be returned, update 

<Response>mock-servicecallout</Response>

to

<Response>response</Response>

@ssvaidyanathan thank you so much for keep replying and guide me finally I am able to do so 

Glad you got it to work