I am working with Backgrid these days. Trying to edit a row value and to persist the database object, I end up with the following HTTP error:
NetworkError: 405 Method Not Allowed - http:// localhost:8084/fsrtool/api/roles/5
My web application driven by a Java Spring backend. The Backgrid frontend is supposed to call the following method:
@GET
@Path("/{id}")
@Produces(MediaType.APPLICATION_JSON)
@Override
public Role getById(@PathParam("id") Long id) {
LOG.info("get a role with its ID");
Role r = rds.getById(id);
return r;
}
I know that my service class is working, because I am able to create new 'Roles' from the Backgrid table and thanks to the following method:
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Override
public Response create(final Role r) {
return Response.status(Status.CREATED).entity(rds.getOrSave(r)).build();
}
Investigating the problem, I figured out that backgrid sent the request with PUT method. I then tried several changes into my service class in order to handle this request, but I have not been able to find the good way of setting this up.
Would you know how Backgrid cells should be edited?
So, as the application I'm working on seems to be designed, I actually was not using the good library...
The way I need my service method to be:
@PUT
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}")
public Response update(final Role r, @PathParam("id") Long id) {
// do some processing... save to the db
}