Exporting and Importing WSO2 APIs

Nethmini Romina
3 min readSep 9, 2019

--

WSO2 is one of the leading open-source software companies which provide Service Oriented Architecture (SOA) middleware with API Management, Enterprise Integration, ESB and Identity Management technologies. This article is based on how to export and import APIs in WSO2 API Manager.

Image credits: https://opensource-it.com/wso2-tungsten/wso2-api-manager-logo/

Prerequisite:

  • You can need to download WSO2 API Manager latest version from https://wso2.com/api-management/ and start the server (Run wso2server.sh file inside the bin folder)
  • After download export-import tool {export-import.war} and copy it to <API-M_HOME>/repository/deployment/server/webapps folder.
  • Then download the API Manager Dev-Ops Tooling. Extract the zip file and navigate to the folder.

Execute command;

./apimcli

To verify the installation, check whether a folder named .wso2apimcli is created in $HOME directory. Inside this folder, you will find a few configuration files.

Using this apimcli you can create and delete environments while exporting and importing using them. As the first step, we will create an environment named “production”. To create environments, there are a few mandatory flags to be completed.

Example:

  • -n <environment name>
  • - -registration <registration endpoint>
  • - -apim <apim endpoint>
  • - -token <token endpoint>
  • - -import-export <endpoint for environment>
  • - -admin <admin REST API endpoint>
  • - -api_list <api list endpoint>
  • - -app_list <app list endpoint>

After creating the environment, you can export the APIs. Before exporting you must have create an API in WSO2 API Publisher. Here I have a sample API.

Now using execute the command,

apimcli export-api -n <name> -v <version> -r <provider> -e <environment> -k

Here also there are few mandatory flags for executing the command.

  • -n = API name
  • -v = version
  • -r = provider
  • -e = environment
  • -k is a global flag which is used to allow connections to SSL sites without certs

You can find the exported folder in the directory. The final part is to import the API. To import the API first you have to do is navigate to the directory where the exported API file is. Then execute the following command;

apimcli import-api -f <file> -e <environment> -k

The mandatory flags are:

  • -f = the file
  • -e = environment
  • -k, to allow connections to SSL sites without certs

If the API already exists in the APIM it will give an error as;

For more information refer WSO2 API Manager docs on Migrating the APIs and Applications to a Different Environment.

Reference:

--

--

No responses yet