Skip to content

Commit

Permalink
Allowing more positive HTTP status codes.
Browse files Browse the repository at this point in the history
  • Loading branch information
chisou committed Jan 8, 2024
1 parent c4c4309 commit 258b441
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions c8y_api/_base_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def post(self, resource: str, json: dict, accept: str = None, content_type: str
raise KeyError(f"No such object: {resource}")
if 500 <= r.status_code <= 599:
raise SyntaxError(f"Invalid POST request. Status: {r.status_code} Response:\n" + r.text)
if r.status_code not in (200, 201):
if r.status_code not in (200, 201, 204):
raise ValueError(f"Unable to perform POST request. Status: {r.status_code} Response:\n" + r.text)
if r.content:
return r.json()
Expand Down Expand Up @@ -269,7 +269,7 @@ def put(self, resource: str, json: dict, params: dict = None,
raise KeyError(f"No such object: {resource}")
if 500 <= r.status_code <= 599:
raise SyntaxError(f"Invalid PUT request. Status: {r.status_code} Response:\n" + r.text)
if r.status_code != 200:
if r.status_code not in (200, 202, 204):
raise ValueError(f"Unable to perform PUT request. Status: {r.status_code} Response:\n" + r.text)
if r.content:
return r.json()
Expand Down

0 comments on commit 258b441

Please sign in to comment.