Open Closed

Failed to load API definition #3109


User avatar
0
OsmanAmanjee created
  • ABP Framework version: latest
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): yes / no
  • Exception message and stack trace:
  • Failed to load api defintion. response status is 404 https://medistat.co.za/medistatapi/swagger/swagger/v1/swagger.json
  • Steps to reproduce the issue:"
  • After deploying my application to IIS, I'm not able to open the swagger ui. Below are my configuration details.

{ "App": { "SelfUrl": "https://medistat.co.za/MedistatApi", "AngularUrl": "https://medistat.co.za/MedistatWeb", "CorsOrigins": "https://.Medistat.com,https://medistat.co.za/MedistatWeb", "RedirectAllowedUrls": "https://medistat.co.za/MedistatWeb" }, "Redis": { "Configuration": "127.0.0.1" }, "ConnectionStrings": { "Default": "Server=MedistatDB;Database=MedistatABP;Trusted_Connection=false;User ID=MedistatUser;Password=L#vaH4buZ25WjB9;Connect Timeout=1000", "Discovery": "Server=MedistatDB;Database=MedistatABPDiscovery;Trusted_Connection=false;User ID=MedistatUser;Password=L#vaH4buZ25WjB9;Connect Timeout=1000", "Edi": "Server=MedistatDB;Database=MedistatABPEdi;Trusted_Connection=false;User ID=MedistatUser;Password=L#vaH4buZ25WjB9;Connect Timeout=1000", "Msv": "Server=MedistatDB;Database=MedistatABPMsv;Trusted_Connection=false;User ID=MedistatUser;Password=L#vaH4buZ25WjB9;Connect Timeout=1000" }, "AuthServer": { "Authority": "https://medistat.co.za/MedistatApi", "RequireHttpsMetadata": "false", "SwaggerClientId": "Medistat_Swagger", "SwaggerClientSecret": "1q2w3e" }, "StringEncryption": { "DefaultPassPhrase": "fsfXFsKSwfobK4Fr" },


9 Answer(s)
  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    Your swagger UI configuration doesn't seem correct.

    https://medistat.co.za/medistatapi/swagger/swagger/v1/swagger.json seems to have extra /swagger https://medistat.co.za/medistatapi/swagger/v1/swagger.json works

  • User Avatar
    0
    OsmanAmanjee created

    Hi

    Thanks very much for this, not sure where that extra bit of configuration came from. The fix you suggested has solved that problem. But I'm still not able to use the API correctly in swagger. It seems its a CORS issue. I've pasted a snippet from the log file as well as the configuration file. I'm not sure what I'm doing wrong because as you can see in the configuration ive configured CORS. Is there another place that this also needs to be configured

    2022-05-19 12:21:41.001 +02:00 [INF] CORS policy execution failed. 2022-05-19 12:21:41.001 +02:00 [INF] Request origin http://medistat.co.za does not have permission to access the resource. 2022-05-19 12:21:41.008 +02:00 [INF] No CORS policy found for the specified request. 2022-05-19 12:21:41.009 +02:00 [INF] Executing endpoint 'Volo.Abp.Account.Public.Web.Areas.Account.Controllers.AccountController.Login (Volo.Abp.Account.Pro.Public.Web)' 2022-05-19 12:21:41.027 +02:00 [INF] Route matched with {controller = "Login", area = "account", action = "Login", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[Volo.Abp.Account.Public.Web.Areas.Account.Controllers.Models.AbpLoginResult] Login(Volo.Abp.Account.Public.Web.Areas.Account.Controllers.Models.UserLoginInfo) on controller Volo.Abp.Account.Public.Web.Areas.Account.Controllers.AccountController (Volo.Abp.Account.Pro.Public.Web). 2022-05-19 12:21:41.635 +02:00 [INF] Try to use LDAP for external authentication 2022-05-19 12:21:41.704 +02:00 [WRN] Ldap login feature is not enabled!

    "App": { "SelfUrl": "https://medistat.co.za/MedistatApi", "AngularUrl": "https://medistat.co.za/MedistatWeb", "CorsOrigins": "https://*.Medistat.com,https://medistat.co.za/MedistatWeb,http://medistat.co.za/MedistatWeb,https://localhost:4200", "RedirectAllowedUrls": "https://localhost:4200" },

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    "CorsOrigins": "https://*.Medistat.com,https://medistat.co.za/MedistatWeb,http://medistat.co.za/MedistatWeb,https://localhost:4200",

    You allow https://medistat.co.za but you are making request from http.

  • User Avatar
    0
    OsmanAmanjee created

    Yes I see that, I'm allowing both http and https in the config. I'm not sure why its making the request in http though because the site is deployed and configured in IIS to use https

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    Did you add http://medistat.co.za? Does it solve the problem?

  • User Avatar
    0
    OsmanAmanjee created

    Yes I have tried a few different combinations, I have no idea why its making the request as an http instead of an https "App": { "SelfUrl": "https://medistat.co.za/MedistatApi", "AngularUrl": "https://medistat.co.za/MedistatWeb", "CorsOrigins": "https://*.Medistat.com,https://medistat.co.za/MedistatWeb,http://medistat.co.za/MedistatWeb,http://medistat.co.za,https://medistat.co.za,https://localhost:4200", "RedirectAllowedUrls": "https://localhost:4200" },

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    t seems like a misconfiguration in IIS URL rewrite settings.

  • User Avatar
    0
    OsmanAmanjee created

    As you can see from the attached picture, I dont have IIS Url Rewrite configured at all.

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    It is hard to follow the problem, let's go on step by step. You couldn't load the API definition because of the wrong URL (extra swagger on URL). It is fixed. You had problems with CORS. Is this problem fixed?

    Also, If you have problems with IIS, I suggest asking in also StackOverflow to get a faster response since it is not related to ABP.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15