redirecting to login page for auth code

hi,

i have tried to below code for redirection .

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage name="AssignMessage-AuthzCodeResponse">
  <DisplayName>AssignMessage-AuthzCodeResponse</DisplayName>
  <Description>Assigns the response message for an /authorize call</Description>
  <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
  <AssignTo createNew="true" type="response">response</AssignTo>
  <Remove>
    <Payload>true</Payload>
  </Remove>
  <Set>
    <StatusCode>302</StatusCode>
    <ReasonPhrase>redirected to login </ReasonPhrase>
    <Headers>
      <Header Name="location">{loginurl}</Header>
    </Headers>
    <QueryParams/>
    <FormParams/>
  </Set>
  <IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
</AssignMessage>

in trace its showing its redirecting, but in the browser i am not getting the redirected page .

That should work, if it is attached to the flow in the right location.

You need to attach that to the Response flow. Have you done that?

It’s possible for you to attach the policy into the Request flow. It will assign to the response message, as desired. But at the start of the Response flow, Apigee will reset the response message. In other words, if you attach the AssignMessage policy into the Request flow, Your assignment will always be overwritten. That could be what you’re seeing.

I think Apigee ought to warn you about using AssignMessage to set values into the response object with a policy attached to the Request flow. I can’t think of a good reason to ever do that.

Thanks its worked removed that remove payload tags and its worked