My application is developed using spring framework.I have created a new rest webservice using spring framework.
@Controller
public class MyTestController {
@Inject
private MyService service;
@RequestMapping(value = "/acc/Status/{accNum}", method = RequestMethod.GET)
@ResponseBody
public String getAccStatus(@PathVariable final String accNum, final HttpServletResponse response) throws Exception
{
//logic goes here
return "success";
}
MyService:
public interface BusinessCalendarService {
//methods..
}
I want to see the response of the above webservice. I am using postman tool to see the responses.
When i gave the request as
http://localhost:8080/myApplication/rest/acc/Status/322298973, it is showing the below message.
HTTP Status 401 - Full authentication is required to access this resource
The existing controllers works fine, it is with my controller which is showing the above message. Please suggest do i need to do any code modifications? I have followed the same way as other controllers were written.
You either need to authenticate the user before posting to that uri, or, if it's a uri that should be able to be accessed without being authenticated, add the uri to your authorizeRequests().antMatcher()
within the http security part of your config.
https://docs.spring.io/spring-security/site/docs/3.2.8.RELEASE/apidocs/org/springframework/security/config/annotation/web/builders/HttpSecurity.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With