Api Error Resolver
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site
Spring Boot Rest Error Handling
About Us Learn more about Stack Overflow the company Business Learn more about spring rest error handling hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join
Spring Boot Error Handling
the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up DefaultInlineContraintResolver Error in WebAPI spring @exceptionhandler 2 up vote 44 down vote favorite 4 I'm using Web API 2 and I'm getting the following error when I send a POST to my API method using IIS 7.5 on my local box. The inline constraint resolver of type 'DefaultInlineConstraintResolver' was unable to resolve the following inline constraint: 'string'. Line 21: GlobalConfiguration.Configuration.EnsureInitialized(); None of my APIs work using IIS. However, I'm able to spring rest exception handling json run my API project in Visual Studio using IIS Express and successfully make a POST to my login API, but when I try and make a GET request to another API call, I get the constraint resolver error. In order to troubleshoot this, I created a brand new Web API 2 project in Visual Studio and started importing the existing APIs into the new project one at a time and running them to ensure they work. Using IIS Express with this new project, I get the same exact results as I did with my existing API project. What am I missing here? Even with a brand new project I'm not able to make GET requests without running into this constraint resolver issue. c# asp.net api iis asp.net-web-api share|improve this question asked May 1 '14 at 16:30 Halcyon 4,85484175 add a comment| 2 Answers 2 active oldest votes up vote 71 down vote accepted As the error indicates, the DefaultInlineConstraintResolver that Web API ships with does not have an inline constraint called string. The default supported ones are the following: // Type-specific constraints { "bool", typeof(BoolRouteConstraint) }, { "datetime", typeof(DateTimeRouteConstraint) }, { "decimal", typeof(DecimalRouteConstraint) }
(part 2) by Les Hazlewood | May 22, 2012 |JavaREST APIIn part 1 of this 2-part series, we discussed a best-practice error representation (format) that should be returned to a REST API caller https://stormpath.com/blog/spring-mvc-rest-exception-handling-best-practices-part-2 when an error is encountered.In this article (part 2), we’ll https://sling.apache.org/apidocs/sling7/org/apache/sling/api/resource/ResourceResolverFactory.html show how to produce those representations from a REST API written using Spring MVC.Spring Exception HandlingSpring MVC has two primary ways of handling exceptions that are thrown when invoking an MVC Controller: the HandlerExceptionResolver and the @ExceptionHandler annotation.HandlerExceptionResolvers error handling are great for handling Exceptions in a uniform way and are ideal as framework components that can do heavy lifting for you. The @ExceptionHandler annotation is a good choice if you want to manually perform some logic based on a specific Exception instead.Both of these mechanisms are extremely powerful: rest error handling our normal code can throw exceptions as expected in a type-safe manner to indicate exactly why something failed, with all of the OO benefits that implies. Then we can let the resolver and/or handler do the Exception–to– HTTP translation work as necessary. You know - separation of concerns and all that good stuff.For our REST exception handling, we want all errors to be represented in the same way in a best-practices manner. Because of this uniformity, the HandlerExceptionResolver approach is ideal. We’ll present a REST-friendly HandlerExceptionResolver implementation that can be used in any REST API.RestExceptionHandlerWhile most existing HandlerExceptionResolver implementations are suitable for Spring MVC-based user interfaces, they don’t quite hit that ‘sweet spot’ for REST error handling. To get exactly what we want based on Part 1’s representation format, we’ve created our own HandlerExceptionResolver implementation, called the RestExceptionHandler.Tip: This code discussed in this
Interface ResourceResolverFactory All Known Subinterfaces: JcrResourceResolverFactory @ProviderType public interface ResourceResolverFactory The ResourceResolverFactory defines the service API to get and create ResourceResolvers. As soon as the resource resolver is not used anymore, ResourceResolver.close() should be called. All resource resolvers returned by the same resource resolver factory must use the same search path Since: 2.1 Field Summary Fields Modifier and Type Field and Description static String PASSWORD Name of the authentication information property providing the password of the user for which to create a resource resolver. static String SUBSERVICE Name of the authentication information property providing the Subservice Name for the service requesting a resource resolver. static String USER Name of the authentication information property providing the name of the user for which the getResourceResolver(Map) method creates resource resolvers. static String