I am trying to import an API I have into Azure API Management using swagger, should be fairly simple but I always get the same error:
One or more fields contain incorrect values: API with specified name already exists
I do not have ANYTHING setup in Azure API management yet, very frustrating.
UPDATE
I am using Swashbuckle (https://github.com/domaindrivendev/Swashbuckle) to add Swagger to my WebAPI project.
It is generating Swagger 2.0 docs.
Here is the info element of the Swagger Doc:
swagger: "2.0",
info: {
version: "v3",
title: "ShopZioAPIv3"
},
It does not matter what I change that to, I still always get:
One or more fields contain incorrect values: API with specified name already exists
The Azure API Management error, "API with specified name already exists," can be misleading, and in this case, it is inaccurate.
As discussed in Darrel Miller's answer, invalid Swagger can cause this issue. Although multiple operation objects with the same OperationId is invalid in Swagger 2.0, I think the core issue you are having is that Azure API Management does not yet support Swagger 2.0 (as of Dec 1, 2015).
Swashbuckle 5+ generates only Swagger 2.0 so some,if not all, definitions generated with it will fail with this error -- even well-formed Swagger definitions validated by http://editor.swagger.io, which also seems to only support Swagger 2.0.
Swashbuckle 4.2 supports generating Swagger 1.2 definitions.
Also, I was able to take my Swagger 2.0 definition (generated by Swashbuckle 5), and convert it to Swagger 1.2 using Restlet Studio.
I my case the title
{"info":{"title": "API-NAME",...
in the Swagger file did not match the name of the selected API (because we had created several test APIs).Simply changing the string value fixed it.
That error message appears when you don't specify a unique API prefix.
I realize that you said that you don't have anything already already setup in the API however, if you could try putting some unique value in this field:
An API Management service instance is designed to host multiple APIs, so the prefix is used to differentiate between the APIs by using the first part of the path.
The subdomain part of the URL is used to identify the service. e.g.
Update
Based on the provided Swagger, the problem comes from multiple operation objects with the same OperationId. This is invalid swagger.
Usually Swashbuckle will fail before generating operations with duplicate Ids. There is a ResolveConflictingActions method that allow you to put your own code to deal with these cases. It seems like in this case the resolution code is not doing the right thing.