Ask Your Question
4

What is the process for using the API Manager custom policy to make an endpoint call and storing the response in the Property Mediator?

asked 2022-05-20 11:00:00 +0000

huitzilopochtli gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2022-04-20 03:00:00 +0000

scrum gravatar image

To use the API Manager custom policy to make an endpoint call and store the response in the Property Mediator, follow these steps:

  1. Create a new custom policy in the WSO2 API Manager.
  2. Copy and paste the following code into the custom policy:
<policies>
   <inSequence>
      <log level="full"/>
      <send>
         <endpoint>
            <address uri="http://example.com/api"/>
         </endpoint>
      </send>
   </inSequence>
   <outSequence>
      <property name="responsePayload" expression="$body"/>
      <log level="full"/>
      <send/>
   </outSequence>
</policies>
  1. Replace "http://example.com/api" with the URL of the endpoint you want to call.
  2. Save the custom policy.
  3. Apply the custom policy to an API in the WSO2 API Manager.
  4. Make a request to the API.
  5. Check the logs of the API Manager to see the full response from the endpoint.
  6. You can access the response by using the Property Mediator with the following expression:
<property name="responsePayload" expression="get-property('responsePayload')"/>
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-05-20 11:00:00 +0000

Seen: 11 times

Last updated: Apr 20 '22