Units¶
API endpoint for manage units.
Data management¶
/api/units
¶
-
GET
/storekeeper/api/units
¶ List units
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
Example request:
GET /storekeeper/api/units HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json [ { "id": 1, "unit": "m" }, { "id": 2, "unit": "pcs" } ]
-
POST
/storekeeper/api/units
¶ Create unit
Status Codes: - 201 Created – no error
- 401 Unauthorized – user was not logged in
- 422 Unprocessable Entity – there is wrong type / missing field / unit is already exist
Example request:
POST /storekeeper/api/units HTTP/1.1 Host: localhost:8000 Content-Type: application/json { "unit": "m" }
Example response:
HTTP/1.0 201 CREATED Content-Type: application/json { "id": 1, "unit": "m" }
/api/units/<id>
¶
-
GET
/storekeeper/api/units/
(int: id)¶ Get unit
Parameters: - id – ID of selected unit for get
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no unit
Example request:
GET /storekeeper/api/units/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "id": 1, "unit": "m" }
-
PUT
/storekeeper/api/units/
(int: id)¶ Update unit
Parameters: - id – ID of selected unit for put
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no unit
- 422 Unprocessable Entity – there is wrong type / missing field / unit is already exist
Example request:
PUT /storekeeper/api/units/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json { "unit": "dl" }
Example response:
HTTP/1.0 200 OK Content-Type: application/json { "id": 1, "unit": "dl" }
-
DELETE
/storekeeper/api/units/
(int: id)¶ Delete unit
Parameters: - id – ID of selected unit for delete
Status Codes: - 200 OK – no error
- 401 Unauthorized – user was not logged in
- 404 Not Found – there is no unit
Example request:
DELETE /storekeeper/api/units/1 HTTP/1.1 Host: localhost:8000 Content-Type: application/json
Example response:
HTTP/1.0 200 OK Content-Type: application/json null