Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Redirect using Assign Message policy

Hi @anilsagar ,

Flow:
Client > ASGW > Target 1> (Redirect Assign Message Policy) > Target 2

We have a request which first should be sent to target 1 and in response to it we will receive Status Code:303 and header with URL of the second target (Target2).

We are using Assign Message policy to redirect to target 2

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage async="false" continueOnError="false" enabled="true" name="AM-Redirect">
    <DisplayName>RedirectOffers</DisplayName>
    <Properties/>
    <Set>
        <StatusCode>303</StatusCode>
        <Headers>
            <Header name="Location">{target.response.url}>
        </Headers>
    </Set>
    <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
    <AssignTo createNew="true" transport="http" type="request"/>
</AssignMessage>

We have added the below code in TargetEndPoint PostFlow response

 

 

<PostFlow name="PostFlow">
        <Request/>
        <Response>
            <Step>
                <Name>AM-Redirect</Name>
            </Step>
        </Response>
    </PostFlow>

 


We are able to successfully redirect and get status code: 200 but not able to receive the response body.
Could you please help?

Solved Solved
1 13 2,046
1 ACCEPTED SOLUTION

I believe that explanation covered how to use Apigee to SEND a 302 response back to the requesting client.

"To issue a redirect from Apigee Edge, you can use the AssignMessage policy. ...

The wording is a little odd, but "issue a redirect" implies "send a 30x back to the requester."   It does not mean that the AssignMessage policy FOLLOWS a redirect. As I said above, the AssignMessage policy does not follow redirects. 

The AssignMessage policy can be used to modify the current request or response message, or some other message. You can set verbs, status codes, payloads, headers, queryparams, and so on.  Effectively AssignMessage allows you to alter an in-memory representation of a thing, inside the API Proxy.  The policy performs no communication. 

View solution in original post

13 REPLIES 13