I received the error "Unable to find an OpenAPI description" while running the API tutorial at https://learn.microsoft.com/en-us/training/modules/build-web-api-aspnet-core/3-exercise-create-web-api

Stanley, Eugene 10 Reputation points
2024-05-10T14:06:11.3866667+00:00

https://learn.microsoft.com/en-us/training/modules/build-web-api-aspnet-core/3-exercise-create-web-api

When connecting to localhost using httprepl and https, I received the error "Unable to find an OpenAPI description". I am using .NET8User's image

According to the tutorial, this could be caused by an improperly configured dev certificate. Inspecting the certificate shows it is installed properly. User's image

Further research outside the tutorial revealed my issue to be launch settings. Performing the steps on my machine as outlined in the tutorial, the service was not listening at all for https requests.User's image

I think the tutorial could be improved by mentioning to try the command "dotnet run --launch-profile https" or to otherwise modify the launchsettings.json file. This is because recent releases of .NET default to the first profile listed in launchsettings.json when using dotnet run.User's image

User's image

Has anyone else in the community has come across this issue, or has anyone found an alternative solution?

This question is related to the following Learning Module

Community Center | Not monitored
{count} votes

2 answers

Sort by: Most helpful
  1. Ali Muhammed Patrash 30 Reputation points
    2024-12-14T19:27:37.0533333+00:00

    How do you do?

    I had the same issue but resolved it with

    • Adding "/openapi/openapi.json" as an argument to the call app.MapOpenApi();

    Screenshot From 2024-12-14 22-19-18

    • Starting httprepl with an extra parameter --openapi /openapi/openapi.jsonUser's image
    6 people found this answer helpful.

  2. Pradeep M 9,765 Reputation points Microsoft External Staff Volunteer Moderator
    2024-05-11T02:52:14.7566667+00:00

    Hi Stanley, Eugene,

    Thank you for reaching out to Microsoft Q & A forum.     

    I have finished the tutorial exercise on,  Creating a Web API Project , and I found the instructions straightforward and easy to follow. Following them, I managed to set up a new API application. 

    1.Build and test the web API 

    Following the successful build of the web API application, it can be executed from the command line interface. Upon execution, the application will be allocated a specific port number. Subsequently, you can access the application by launching a web browser and entering the URL: https://localhost:{PORT}/weatherforecast, substituting "{PORT}" with the assigned port number. This action will yield the desired results presented in JSON format 

    I've attached a screenshot for your reference: 

    portnumber

    weatherdetails

    1. Explore with .http files 

    Before going through the .http files you must install REST Client extension  

     Then after going through explore with .http files.  

     1.Open the ContosoPizza.http file.  

     This file has been pre-configured with the @ContosoPizza_HostAddress variables and a GET command calling /weatherforecast/ that accepts application/json.  

     2.Select the Sent Request command above the GET which will send a request to the running service.  

    I've attached a screenshot for your reference: 

    sendrequest1

    Please feel free to contact us if you have any additional questions. 

    If you have found the answer provided to be helpful, please click on the "Accept answer/Upvote" button so that it is useful for other members in the Microsoft Q&A community.   

    Thank you. 

    1 person found this answer 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.