spring2885 / backend

Backend Repository for Spring2885 (REST + Server Side Java + Database)
1 stars 0 forks source link

edited PersonTypeApi. Still not fixed #201

Closed mktecson closed 8 years ago

mktecson commented 8 years ago

@rob2885 i fixed the Api to accept a Request body of PersonType. I changed the POST test too. It succeeds. But when i run the server and go to localhost:8888 and go to the PersonTypeApi, when i try a post i am getting a 500 error.

Internal Server Error "message": "could not execute statement; nested exception is org.hibernate.exception.GenericJDBCException: could not execute statement"

I also try putting in the example value from swagger. and i get a 400 bad request

rob2885 commented 8 years ago

need more of the error than what you provided. the nested exception will be the real interesting one.

mktecson commented 8 years ago

When i run PersonTypeApiTest, method testPersonTypePost() gets a 400 error. MissingServletRequestParameterException: Required PersonType parameter 'type' is not present

mktecson commented 8 years ago

This is the response body when i try it from the swagger UI { "timestamp": 1460488734174, "status": 400, "error": "Bad Request", "exception": "org.springframework.web.bind.MissingServletRequestParameterException", "message": "Required PersonType parameter 'type' is not present", "path": "/api/v1/persontype" }

mktecson commented 8 years ago

@rob2885 is it supposed to be @RequestBody PersonType type or @RequestBody() PersonType type. Either way. the API test works. just in the swagger getting some errors.

rob2885 commented 8 years ago

So @requestbody seems to work for me. The error now is

java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed
rob2885 commented 8 years ago

Removing the readonly=true from the @Transactional annotation should fix that.

rob2885 commented 8 years ago

Ok.. next error is now:


java.lang.NullPointerException: null
    at org.spring2885.server.db.model.PersonTypeConverter$JsonToDbConverter.apply(PersonTypeConverter.java:37) ~[classes/:na]
    at org.spring2885.server.api.PersonTypeApi.post(PersonTypeApi.java:105) ~[classes/:na]
rob2885 commented 8 years ago

and now it works.. I posted this:

{
  "name": "staff"
}
rob2885 commented 8 years ago

I went ahead and just fixed it and merged it. Please look at my last commit to see what I changed.

mktecson commented 8 years ago

Thanks rob. Will look over your commit right now. Im gonna go ahead and look for bugs.