Change the Default Mediation Flow of API Requests
com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links' is unknown.

Change the Default Mediation Flow of API Requests

The API Gateway has a default mediation flow for the API invocation requests that it receives. You can extend this default mediation flow to do additional custom mediation for the messages in the API Gateway. An extension is provided as a synapse mediation sequence. You design all sequences using a tool like WSO2 Developer Studio and then store the sequence in the Gateway's registry. 

Please note that following mediators are not usable within custom sequences since they are not supported by API Gateway custom medications.

  • Call mediator in non-blocking mode

  • Send mediator

Let's see how to create a custom sequence using WSO2 Developer Studio and then deploy and use it in your APIs.

  1. Log in to the API Publisher.

  2. Click Add to create an API with the following information and then click Implement.

  3. The Implement tab opens. Provide the information given in the table below and click Manage.

  4. Click Manage to go to the Manage tab, provide the following information and click Save & Publish once you are done.

     

  5. Download WSO2 Developer Studio (version 3.7.1 is used here) from http://wso2.com/products/developer-studio/ and open it by double clicking the Eclipse.app file inside the downloaded folder. 

  6. Click the Developer Studio menu and choose Open Dashboard. When the dashboard opens, click the ESB Config Project link.

  7. Create a new ESB project by the name YahooConfigProject.

  8. Click the Sequence link on the Developer Studio Dashboard and create a new sequence by the name YahooWeatherSequence and the YahooConfigProject project.

  9. Your sequence now appears on the Developer Studio console. From under the Mediators section, drag and drop a property mediator to your sequence and give the following values to the property mediator.

  10. Similarly, add another property mediator with the following values. This is an HTTP transport property that appends its value to the address endpoint URL. Once you are done, save the sequence.

  11. Log in to the API Gateway's management console (https://localhost:9443/carbon) as admin. 

  12. After logging in, click the Browse menu under the Resources menu. 

  13. When the API Gateway's registry opens, navigate to the registry path /_system/governance/apimgt/customsequences/in
    This is because you want the custom sequence to be invoked in the In direction or the request path. If you want it to be involved in the Out or Fault paths, select the respective location under customsequences.

  14. Click Add Resource and upload the XML file of the sequence that you created earlier.

  15. Log back in to the API Publisher, select the API that you created earlier and click the Edit link right next to its name to go to the edit wizard. 

  16. Navigate to the API's Manage tab, click the check box next to sequences and select the sequence that you created for the In flow. Next, Save & Publish the API again.

  17. Open the API Store, subscribe to the API that you just published and generate the access tokens in order to invoke the API.

  18. Click the API Console tab of the API. It opens the integrated API Console using which you can invoke the API.

  19. Give the following values for the parameters and invoke the API. You can also give any other value of your choice.

  20. Note the response that you get as a JSON object from Yahoo.

In this tutorial, you created a sequence to change the default mediation flow of API requests, deployed it in the API Gateway and invoked an API using the custom mediation flow.

 

com.atlassian.confluence.content.render.xhtml.migration.exceptions.UnknownMacroMigrationException: The macro 'next_previous_links2' is unknown.