Skip to content

Error when importing all APIs deployed in a APIM gateway when a API Product is present #3732

@chira99

Description

@chira99

Description

An error occurs when running the following command:

micro-gw import -l <Gateway_environment>  <project_name>

Error raised:

micro-gw: Error while reading the response as extended APIs

Expected:

All API products, MCP servers and APIs should be imported to the microgateway. This currently works when there are only APIs, and no API products or MCP servers are deployed in the gateway.

ID for API with name <API_name> : api_30e623704c5c5479b7c0d9ab78e965df02c1610401e37cbd557e6353e3191c76
ID for API with name My API : api_55ab4b6434c427c553ffd0937b2727b049a8006b39e5cdfd6020fe13a9b75c65

Steps to Reproduce

The issue was identified when importing from both APIM 4.5.0 and APIM 4.6.0

  1. Create and deploy few APIs and also an API Product.
  2. Configure APIM with the Microgateway as documented in [1]
  3. Run the following command to import all deployments of that (Default) gateway.
micro-gw import -l <Gateway_environment>  <project_name>

For APIM 4.6.0: The error also occurs if the gateway has an MCP server deployed.

[1] https://mg.docs.wso2.com/en/latest/how-tos/adding-apis/importing-a-single-api-from-wso2-api-manager/

Version

3.2.10

Environment Details (with versions)

No response

Relevant Log Output

[2025-09-25 14:11:21,237] ERROR {org.wso2.apimgt.gateway.cli.cmd.Main} - Error while reading the response as extended APIs 
org.wso2.apimgt.gateway.cli.exception.CLIRuntimeException: Error while reading the response as extended APIs
	at org.wso2.apimgt.gateway.cli.utils.RESTAPIUtils.getResponseAsExtendedApis(RESTAPIUtils.java:130)
	at org.wso2.apimgt.gateway.cli.rest.RESTAPIServiceImpl.exportAPIs(RESTAPIServiceImpl.java:477)
	at org.wso2.apimgt.gateway.cli.cmd.ImportCmd.execute(ImportCmd.java:262)
	at java.util.Optional.ifPresent(Optional.java:159)
	at org.wso2.apimgt.gateway.cli.cmd.Main.main(Main.java:50)
Caused by: java.io.FileNotFoundException: /Users/chirantha/Documents/APIM/MGW/TestMGW/old_project/exported-api6774454438768187572/TestAPIProduct-1.0.0/api.json (No such file or directory)
	at java.io.FileInputStream.open0(Native Method)
	at java.io.FileInputStream.open(FileInputStream.java:195)
	at java.io.FileInputStream.<init>(FileInputStream.java:138)
	at com.fasterxml.jackson.core.TokenStreamFactory._fileInputStream(TokenStreamFactory.java:318)
	at com.fasterxml.jackson.core.JsonFactory.createParser(JsonFactory.java:1208)
	at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3711)
	at org.wso2.apimgt.gateway.cli.utils.RESTAPIUtils.getResponseAsExtendedApis(RESTAPIUtils.java:113)
	... 4 more

Related Issues

No response

Suggested Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions