I have develop a REST API using Spring Boot and IntelliJ IDEA. That API is up and running. It is accessible by Postman & it gives the relevant JSON response.
Then I tried to access it from C# windows form application. I tried to add it as a web reference. But that button has been disabled. What is the problem with my code?
@RestController
@RequestMapping("/students")
public class StudentController {
@Autowired
private StudentService studentService;
@RequestMapping(value="/hello")
String home() {
return "Hello World!";
}
@RequestMapping(value="getAllStudents",method = RequestMethod.GET)
public Collection<Student> getAllStudents(){
return studentService.getAllStudents();
}
@RequestMapping(value = "/{id}",method = RequestMethod.GET)
public Student getStudentById(@PathVariable("id") int id)
{
return studentService.getStudentById(id);
}
@RequestMapping(value = "/{id}" , method = RequestMethod.DELETE)
public void deleteStudentById(@PathVariable("id") int id)
{
studentService.removeStudentById(id);
}
If I gives the URL as localhost:8080/students/hello the JSON response come to the visual studio. But it cannot be added as web reference.
What is the solution for this...?