WSO2 am 1.10.0: delete and then recreate an API: "Error occurred while adding the API. A duplicate API already exists for {CONTEXT}"

时间:2016-07-11 20:13:29

标签: wso2 wso2-am

I added an API and later on remove it in /carbon management console. Now I wanted to add it back and it failed with "wso2 am 1.10.0: Error occurred while adding the API. A duplicate API already exists for {CONTEXT}".

I even manually went to database and manually removed the API from all related tables, including AM_API. I also manually removed the related file under /repository/deployment/server/synapse-configs/default/api .

So what else I have to do so I can recreate that API without the above error? Is this a bug in this version?

Related discussion: WSO2 API Manager - context management (Is this issue coming back in Version 1.10.0?)

1 个答案:

答案 0 :(得分:0)

首先要注意的是,您不应该通过碳管理控制台删除api。您看到的xml表示只是运行时逻辑,下面的中介引擎在路由消息时引用它。 WSO2 API Manager中的API有三个方面。

  1. 存储在注册数据库中的元数据
  2. 存储在APIM数据库中的订阅等数据
  3. 运行时API表示形式,存储为xml文件
  4. 现在,首先发生的是,你刚刚删除了xml。但是,告诉api经理关于api的所有其他数据仍然存在。这就是你得到初始错误的原因。手动删除元数据等并不容易。特别是因为您(以及包括我在内的任何其他用户)不知道存储它们的位置。

    因此,删除api的最佳方法是从api发布者UI中删除它或通过api发布者的API删除它。即使您尝试通过以上两种方法删除,如果有任何有效订阅,它也会抱怨。所以,你也必须照顾他们。

    我可以想到以下几点来克服这种情况:

    1. 通过发布商的休息api删除此内容(这是我能看到的最佳选择)

    2. 如果#1不起作用,那么您必须首先检查APIM数据库中的所有条目并删除它们(我无法列出必要的表格等)。然后,如果您熟悉注册表,则可以转到注册表浏览器并遍历到/ _system / governance / apimgt / applicationdata / collection并删除与您的api相关的资源。这可能有助于您清理系统。