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

Is it possible to hardcode the response value instead of getting it via policies?

Hello Team,

I'm new to the APIGEE and exploring. I have a query on below requirement

I want to send the response as "Message sent successfully" if the message is sent to target endpoint successfully

I found a way we can do that using policy in below format 

<Payload contentType="application/json">
{
"Response": " Message sent successfully"

}
</Payload>

Instead of this method, is it possible to write this response directly in the postflow response in any way? 

<PostFlow name="PostFlow">
<Request/>
<Response/>
</PostFlow>

Please help

Thanks,

Dinesh

Solved Solved
0 1 602
1 ACCEPTED SOLUTION

You can use an AssignMessage policy to set the response to whatever value you choose. You would use Set/Payload for that.

You must ATTACH that policy to the response flow, somewhere, in order for it to be executed by Apigee. 

  • ONE PLACE you can attach it is in the Response PostFlow. 
  • ANOTHER PLACE you can attach it is in the Response PreFlow.
  • You can also use the Response Conditional Flow. 

For more on these possible attachment points, consult the documentation.

As an alternative to AssignMessage, you could also use a JavaScript policy to write something into response.content. 

If you choose to use  the JavaScript policy, you would again need to attach it, in the same way as with AssignMessage. 

View solution in original post

1 REPLY 1

You can use an AssignMessage policy to set the response to whatever value you choose. You would use Set/Payload for that.

You must ATTACH that policy to the response flow, somewhere, in order for it to be executed by Apigee. 

  • ONE PLACE you can attach it is in the Response PostFlow. 
  • ANOTHER PLACE you can attach it is in the Response PreFlow.
  • You can also use the Response Conditional Flow. 

For more on these possible attachment points, consult the documentation.

As an alternative to AssignMessage, you could also use a JavaScript policy to write something into response.content. 

If you choose to use  the JavaScript policy, you would again need to attach it, in the same way as with AssignMessage.