Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

full authentication is required to access this resource - Rest webservice call

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.

like image 524
user222 Avatar asked Oct 19 '22 01:10

user222


1 Answers

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

like image 146
Trevor Bye Avatar answered Oct 31 '22 10:10

Trevor Bye