#RestApi Access Problem

4 messages · Page 1 of 1 (latest)

frank coyote
#

When i try to access the Rest Api from postman then i got the html of login i even permit the enpoint of api ```@RestController
@RequestMapping("/api/Student")
@CrossOrigin(origins = "http://localhost:3000")
public class RestApplication {

@Autowired
private StudentDetailsService detailsService;
@Autowired
private BookDetailsRepository booksRepositrory;

//// Get All The Students

@GetMapping("/getAllStudents")
public ResponseEntity<List<StudentDetails>> getAllStudents() {
    Iterable<StudentDetails> studentDetailsIt = detailsService.getAllStudent();
    List<StudentDetails> studentDetails = new ArrayList<StudentDetails>();
    studentDetailsIt.forEach(studentDetails::add);

    if (studentDetails.isEmpty()) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
    return new ResponseEntity<>(studentDetails, HttpStatus.OK);

}```  Security ```SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception {
    httpSecurity.csrf(csrf -> csrf.disable())
            .authorizeHttpRequests(auth -> auth
                    .requestMatchers("/", "/signup", "/processRegister", "/Login", "/login", "/forgot-password/**",
                            "/css/emailVerification.css", "/css/newpassword.css", "css/home.css",
                            "/css/otpchecker.css", "/css/signup.css", "/css/login.css", "/css/resetpassword.css",
                            "/api/Student/**")```
iron steepleBOT
#

This post has been reserved for your question.

Hey @frank coyote! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

violet prairie
#

You use postman to request a list of students. Do you send a cookie in postman?