PagerDuty/pdpyras

rput raises PDHTTPError from JSONDecodeError when adding a user to a team

mpjura opened this issue · 2 comments

Adding a user to a team with client.rput(f'teams/{team}/users/{user}') raises PDHTTPError from JSONDecodeError encountered trying to decode response text. The raw response from put is a 204 with no content.

Removing a user from a team with client.rdelete(f'teams/{team}/users/{user}') does not raise the same error even though the raw response is also a 204 with no content.

Hi @mpjura,

The r* methods assume that the endpoint they are used on has entity wrapping. That does not apply in the case of this endpoint.

One can get around the issue by simply using put instead of rput.

See also: https://pagerduty.github.io/pdpyras/#list-of-non-conformal-endpoints

(Side note: The rdelete method works in this case because it's built around an otherwise universal convention in DELETE endpoints; the expected response is 204 / no content. Endpoints that have wrapped entities however should always respond with JSON to PUT requests.)

got it, thanks @Deconstrained