Issue with using swagger API in version 1.5.21

Product: PowerShell Universal
Version: 1.5.21
Hosted on IIS

We are not able to use swagger endpoint API with role.
When I try to create endpoint w/o it, everything works great.
When I add a role, I get 404. Following can be found in the logs:

2021-10-24T23:55:37.7173660+02:00 0HMCN1PKDIF6F:00000042 [INF] Request starting HTTP/1.1 GET http://f.q.d.n/api/v1/endpoint   (ca22a1cb)
2021-10-24T23:55:37.7187058+02:00 0HMCN1PKDIF6F:00000042 [INF] Authorization was successful. (0d575a54)
2021-10-24T23:55:37.7187298+02:00 0HMCN1PKDIF6F:00000042 [INF] Executing endpoint '"UniversalAutomation.EndpointController.Get (Universal.Server)"' (500cc934)
2021-10-24T23:55:37.7187684+02:00 0HMCN1PKDIF6F:00000042 [INF] Route matched with "{action = \"Get\", controller = \"Endpoint\"}". Executing controller action with signature "System.Collections.Generic.IEnumerable`1[UniversalAutomation.Endpoint] Get()" on controller "UniversalAutomation.EndpointController" ("Universal.Server"). (122b2fdf)
2021-10-24T23:55:37.7188046+02:00 0HMCN1PKDIF6F:00000042 [INF] Executing ObjectResult, writing value of type '"System.Collections.ObjectModel.ReadOnlyCollection`1[[UniversalAutomation.Endpoint, UniversalAutomation.Common, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]"'. (8a1b66c8)
2021-10-24T23:55:37.7189529+02:00 0HMCN1PKDIF6F:00000042 [INF] Executed action "UniversalAutomation.EndpointController.Get (Universal.Server)" in 0.1644ms (afa2e885)
2021-10-24T23:55:37.7189699+02:00 0HMCN1PKDIF6F:00000042 [INF] Executed endpoint '"UniversalAutomation.EndpointController.Get (Universal.Server)"' (99874f2b)
2021-10-24T23:55:37.7190020+02:00 0HMCN1PKDIF6F:00000042 [INF] Request finished in 1.6421ms 200 application/json; charset=utf-8 (791a596a)
2021-10-24T23:55:37.7244976+02:00 0HMCN1PKDIF6F:00000043 [INF] Request starting HTTP/1.1 POST http://dnsapi-test.ams.optiver.com/api/v1/endpoint application/json 2209 (ca22a1cb)
2021-10-24T23:55:37.7256619+02:00 0HMCN1PKDIF6F:00000043 [INF] Authorization failed. (b15dd539)
2021-10-24T23:55:37.7257067+02:00 0HMCN1PKDIF6F:00000043 [INF] AuthenticationScheme: "Cookies" was challenged. (d45f1f38)
2021-10-24T23:55:37.7257216+02:00 0HMCN1PKDIF6F:00000043 [INF] AuthenticationScheme: "Bearer" was challenged. (d45f1f38)
2021-10-24T23:55:37.7267977+02:00 0HMCN1PKDIF6F:00000043 [INF] Authorization failed. (b15dd539)
2021-10-24T23:55:37.7268319+02:00 0HMCN1PKDIF6F:00000043 [INF] AuthenticationScheme: "Cookies" was challenged. (d45f1f38)
2021-10-24T23:55:37.7268459+02:00 0HMCN1PKDIF6F:00000043 [INF] AuthenticationScheme: "Bearer" was challenged. (d45f1f38)
2021-10-24T23:55:37.7268804+02:00 0HMCN1PKDIF6F:00000043 [INF] Request finished in 2.3911ms 401  (791a596a)
2021-10-24T23:55:37.7302309+02:00 0HMCN1PKDIF6F:00000044 [INF] Request starting HTTP/1.1 POST http://dnsapi-test.ams.optiver.com/api/v1/endpoint application/json 2209 (ca22a1cb)
2021-10-24T23:55:37.7315755+02:00 0HMCN1PKDIF6F:00000044 [INF] Authorization was successful. (0d575a54)
2021-10-24T23:55:37.7316072+02:00 0HMCN1PKDIF6F:00000044 [INF] Executing endpoint '"UniversalAutomation.EndpointController.Post (Universal.Server)"' (500cc934)
2021-10-24T23:55:37.7316564+02:00 0HMCN1PKDIF6F:00000044 [INF] Route matched with "{action = \"Post\", controller = \"Endpoint\"}". Executing controller action with signature "System.Threading.Tasks.Task`1[UniversalAutomation.Endpoint] Post(UniversalAutomation.Endpoint)" on controller "UniversalAutomation.EndpointController" ("Universal.Server"). (122b2fdf)
2021-10-24T23:55:37.7326327+02:00 0HMCN1PKDIF6F:00000044 [INF] Executed action "UniversalAutomation.EndpointController.Post (Universal.Server)" in 0.9516ms (afa2e885)
2021-10-24T23:55:37.7326952+02:00 0HMCN1PKDIF6F:00000044 [INF] Executed endpoint '"UniversalAutomation.EndpointController.Post (Universal.Server)"' (99874f2b)
2021-10-24T23:55:37.7344967+02:00 0HMCN1PKDIF6F:00000044 [ERR] An unhandled exception has occurred while executing the request. (48a46595)
System.NullReferenceException: Object reference not set to an instance of an object.
   at UniversalAutomation.EndpointController.Post(Endpoint endpoint) in D:\a\universal\universal\src\Universal.Server\Controllers\EndpointController.cs:line 154
   at lambda_method(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Universal.Server.Middleware.RoutingMiddleware.Invoke(HttpContext httpContext, IPolicyEvaluator policyEvaluator) in D:\a\universal\universal\src\Universal.Server\Middleware\RoutingMiddleware.cs:line 113
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at AspNetCoreRateLimit.RateLimitMiddleware`1.Invoke(HttpContext context) in D:\a\universal\universal\src\AspNetCoreRateLimit\Middleware\RateLimitMiddleware.cs:line 109
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
2021-10-24T23:55:37.7366527+02:00 0HMCN1PKDIF6F:00000044 [INF] Authorization was successful. (0d575a54)
2021-10-24T23:55:37.7366747+02:00 0HMCN1PKDIF6F:00000044 [INF] Executing endpoint '"UniversalAutomation.EndpointController.Post (Universal.Server)"' (500cc934)
2021-10-24T23:55:37.7367161+02:00 0HMCN1PKDIF6F:00000044 [INF] Route matched with "{action = \"Post\", controller = \"Endpoint\"}". Executing controller action with signature "System.Threading.Tasks.Task`1[UniversalAutomation.Endpoint] Post(UniversalAutomation.Endpoint)" on controller "UniversalAutomation.EndpointController" ("Universal.Server"). (122b2fdf)
2021-10-24T23:55:37.7373886+02:00 0HMCN1PKDIF6F:00000044 [INF] Executed action "UniversalAutomation.EndpointController.Post (Universal.Server)" in 0.644ms (afa2e885)
2021-10-24T23:55:37.7374500+02:00 0HMCN1PKDIF6F:00000044 [INF] Executed endpoint '"UniversalAutomation.EndpointController.Post (Universal.Server)"' (99874f2b)
2021-10-24T23:55:37.7389280+02:00 0HMCN1PKDIF6F:00000044 [ERR] An unhandled exception has occurred while executing the request. (48a46595)
System.NullReferenceException: Object reference not set to an instance of an object.
   at UniversalAutomation.EndpointController.Post(Endpoint endpoint) in D:\a\universal\universal\src\Universal.Server\Controllers\EndpointController.cs:line 154
   at lambda_method(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Universal.Server.Middleware.RoutingMiddleware.Invoke(HttpContext httpContext, IPolicyEvaluator policyEvaluator) in D:\a\universal\universal\src\Universal.Server\Middleware\RoutingMiddleware.cs:line 113
   at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
   at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
   at AspNetCoreRateLimit.RateLimitMiddleware`1.Invoke(HttpContext context) in D:\a\universal\universal\src\AspNetCoreRateLimit\Middleware\RateLimitMiddleware.cs:line 109
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
2021-10-24T23:55:37.7400259+02:00 0HMCN1PKDIF6F:00000044 [INF] Request finished in 9.813ms 404  (791a596a)

When I try to use same method on the older versions it works fine.
Any ideas what could be the reason for that?

Can you share the POST body you are providing? It’s likely because the role property is an array and it’s failing to deserialize it. In the past, it was a single value but that changed some time during the 1.5 releases.

It was exactly that. The sad part is that I’ve noticed changes in the format, tried to send JSON with an array and it still failed. I suspect I just made a typo in a hand-crafted JSON I was sending. MrTypo strikes again I guess. :wink:

Thanks for a suggestion!

BTW: I tried to do the same using admin portal and I got 404 there too - perhaps that something worth fixing…?