[Bug]: Update Organization endpoint returns a '405' status
qafui opened this issue · 2 comments
qafui commented
Contact Details
What happened?
Sent an update request to the organization endpoint and received a 405 - method not allowed response.
What is the version of refactor-platform-rs that you're seeing the problem on?
0.1.0
Any related code to produce this issue and relevant log output.
To reproduce,
- start the application with `cargo run -- -t 2 -d [db_url]
- send a PUT request to update an existing organization. e.g.
`curl --request PUT 'localhost:4000/organization/7' \
--header 'Content-Type: application/json' \
--data '{
"name": "Davids Coaching"
}'`
- Results
13:12:17 [DEBUG] (10) hyper::proto::h1::io: parsed 5 headers
13:12:17 [DEBUG] (10) hyper::proto::h1::conn: incoming body is content-length (30 bytes)
13:12:17 [DEBUG] (10) hyper::proto::h1::conn: incoming body completed
13:12:17 [DEBUG] (10) hyper::proto::h1::io: flushed 108 bytes
13:12:17 [DEBUG] (10) hyper::proto::h1::conn: read eof
DB is not updated.
jhodapp commented
Confirmed that the existing Organization entity specified by the Id is not updated and I receive the same backend console output as @qafui.
jhodapp commented
I realized what's going on here. The endpoint route that you specified @qafui in your curl request is missing an 's'. The actual route is a plural "organizations".
This updates Organization entity Id #7 with no problems:
curl --request PUT 'localhost:4000/organizations/7' \
--header 'Content-Type: application/json' \
--data '{
"name": "Davids Coaching"
}'
{"id":7,"name":"Davids Coaching"}
And the backend output:
17:31:36 [DEBUG] (2) hyper::proto::h1::io: flushed 116 bytes
17:31:36 [DEBUG] (2) hyper::proto::h1::conn: read eof
18:32:01 [DEBUG] (2) hyper::proto::h1::io: parsed 5 headers
18:32:01 [DEBUG] (2) hyper::proto::h1::conn: incoming body is content-length (37 bytes)
18:32:01 [DEBUG] (2) hyper::proto::h1::conn: incoming body completed
18:32:01 [DEBUG] (2) web::controller::organization_controller: UPDATE the entire Organization by id: 7, new name: Davids Coaching
18:32:01 [DEBUG] (2) sea_orm::driver::sqlx_postgres: SELECT "organizations"."id", "organizations"."name" FROM "refactor_platform_rs"."organizations" WHERE "organizations"."id" = 7 LIMIT 1
18:32:01 [INFO] summary="SET search_path = 'refactor_platform_rs'" db.statement="" rows_affected=0 rows_returned=0 elapsed=269.458µs
18:32:01 [INFO] summary="SELECT \"organizations\".\"id\", \"organizations\".\"name\" FROM …" db.statement="\n\nSELECT\n \"organizations\".\"id\",\n \"organizations\".\"name\"\nFROM\n \"refactor_platform_rs\".\"organizations\"\nWHERE\n \"organizations\".\"id\" = $1\nLIMIT\n $2\n" rows_affected=0 rows_returned=1 elapsed=1.584208ms
18:32:01 [DEBUG] (9) entity_api::organization: Organization found: Some(Model { id: 7, name: "Jim Hodapp Coaching" })
18:32:01 [DEBUG] (9) entity_api::organization: Existing Organization model to be Updated: Model { id: 7, name: "Jim Hodapp Coaching" }
18:32:01 [DEBUG] (9) sea_orm::driver::sqlx_postgres: UPDATE "refactor_platform_rs"."organizations" SET "name" = 'Davids Coaching' WHERE "organizations"."id" = 7 RETURNING "id", "name"
18:32:01 [INFO] summary="SET search_path = 'refactor_platform_rs'" db.statement="" rows_affected=0 rows_returned=0 elapsed=335.125µs
18:32:01 [INFO] summary="UPDATE \"refactor_platform_rs\".\"organizations\" SET \"name\" …" db.statement="\n\nUPDATE\n \"refactor_platform_rs\".\"organizations\"\nSET\n \"name\" = $1\nWHERE\n \"organizations\".\"id\" = $2 RETURNING \"id\",\n \"name\"\n" rows_affected=0 rows_returned=1 elapsed=2.47ms
18:32:01 [DEBUG] (2) hyper::proto::h1::io: flushed 141 bytes
18:32:01 [DEBUG] (2) hyper::proto::h1::conn: read eof
Closing since I don't think we have any outstanding issue here.