How to import a WEB API 2.0 REST API into APIM

Richard Scannell 426 Reputation points
2023-10-19T13:58:37.43+00:00

I have been looking at this tutorial for Azure API Manager https://learn.microsoft.com/en-us/azure/api-management/import-and-publish, which tells you how to create an API from the JSON stored at https://conferenceapi.azurewebsites.net/?format=json.  

I have a number of REST APIs built in Visual Studio using the WEB API 2.0 Template, which I'd like to import, but I cant find a way to render my API as JSON in the same way as the conference API example.   

My API returns a functioning swagger at https://MyAPi:1234/swagger/ui/index

 

I have tried adding /?format=json to different parts of the url with varying errors

https://MyAPi:1234/swagger/ui/index/?format=json returns 

{"Message":"An error has occurred.","ExceptionMessage":"Mapping not found - index/","ExceptionType":"Swashbuckle.SwaggerUi.AssetNotFound","StackTrace":"   at Swashbuckle.SwaggerUi.EmbeddedAssetProvider.GetAsset(String rootUrl, String path)\r\n   at Swashbuckle.Application.SwaggerUiHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)"}

https://MyAPi:1234/swagger/ui/?format=json returns a 404 not found

 

https://MyAPi:1234/swagger/?format=json redirects me to the https://MyAPi:1234/swagger/ui/index page

 

https://MyAPi:1234/?format=json returns a 404 not found

 

Does anyone have any suggestions?

 

Many thanks 

 

Richard

 

 

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,446 questions
0 comments No comments
{count} votes

Accepted answer
  1. Pramod Valavala 20,656 Reputation points Microsoft Employee Moderator
    2023-10-19T14:17:56.68+00:00

    @Richard Scannell I assume the /swagger/ui/index is the Swagger UI. You should be able to see a link to the Swagger JSON right on that page, correct?

    You could use that directly. Also, make sure the APIM instance can access it (if your Web API is network isolated).

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.