This documentation is for WSO2 API Manager 2.1.0. View documentation for the latest release.

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Reviewed changes

...

  1. Log in to the API Publisher, design a new API with the following information, click Add and then click Next: Implement >.

    Field
    Sample value
    Name
    TestAPI
    Context
    /test
    Version
    1.0.0
    Visibility
    Public
    ResourcesURL pattern/business/{businessId}/address/

    Request types

    GET

  2. The Implement tab opens. Give the information in the table below. 

    FieldSample value
    Endpoint typeHTTP/REST endpoint
    Production endpoint

    http://localhost:8280/businesses/{uri.var.businessId}/details

    Sandbox endpointhttp://localhost:8280/businesses/{uri.var.businessId}/details

  3. Click Next: Manage > to go to the Manage tab, select the Gold tier and publish the API.

    As the API's resource is appended to its endpoint by Synapse at runtime, let's write a custom sequence to remove this appended resource.

  4. Copy the the following to a text editor and save the file in XML format (e.g., TestSequence.xml).

    Code Block
    <sequence xmlns="http://ws.apache.org/ns/synapse" name="TestSequence">
        <property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
    </sequence>
  5. Download and install the WSO2 API Manager Tooling Plug-in if you have not done so already. Open Eclipse by double clicking the Eclipse.app file inside the downloaded folder. 

  6. Click Window > Open Perspective > Other to open the Eclipse perspective selection window. Alternatively, click the Open Perspective icon shown below at the top right corner.
  7. On the dialog box that appears, click WSO2 APIManager and click OK.

  8. On the APIM perspective, click the Login icon as shown below.
  9. On the dialog box that appears, enter the URL, username and password of the Publisher server.
  10. On the tree view that appears, expand the folder structure of the existing API.
  11. Right-click on the in sequence folder and click Import Sequence to import the sequence you create above.
  12. Browse to the TestSequence.xml file you created in step 4.
  13. Your sequence now appears on the APIM perspective. Right-click on the imported sequence and click Commit File to push the changes to the Publisher server.

  14. Log back into the API Publisher, click the Edit link associated with the API and navigate click Edit and go to the Implement tab. Select the Enable Message Mediation check box and engage the In sequence that you created earlier.

    Info

    The task of TestSequence.xml is to remove the URL postfix from the backend endpoint since the URI template of the API's resource is automatically appended to the end of the URL at runtime. Therefore the request URL is modified by adding this sequence to the In flow.

  15. Save and Publish the API.
    You have created an API. Let's subscribe to the API and invoke it.
  16. Log in to the API Store and subscribe to the API.

  17. Click the View Subscriptions button when prompted. The Subscriptions tab opens.

  18. Click the Production Keys tab and click Generate Keys to create an application access token. If you have already generated a token before, click Re-generate to renew the access token. 

  19. Click the API Console tab of your API.

  20. Note that the businessId is added in the UI as a parameter. Give a businessId and click Try it out to invoke the API.

  21. Note the response that you get. According to the mock backend used in this tutorial, you get the response Received Request.

...