On the following lines of code, content-type is set in the http client's _header field during json requests. This causes subsequent requests to break if they rely on a different content-type. For instance, if you call create_application (json data) followed by update_number (form data) using the same Vonage client, it appears to force it to use application/json for the update number call, causing a 420 error.
https://github.com/Vonage/vonage-python-sdk/blob/54fa90ddd0508e52f87c9baa775143afc73cb5d9/http_client/src/vonage_http_client/http_client.py#L264C9-L277
Expected Behavior
The content-type header should be set only for the currently running request
Current Behavior
The content-type header appears to be sticky, and forces incorrect headers on subsequent requests.
Possible Solution
Steps to Reproduce (for bugs)
- Initialize the vonage client and attempt to use it for 2 requests with different content-types (example:
create_application then update_number)
Context
We were debugging an issue with a project that was throwing 420s and was difficult to reproduce. Postman requests, curl requests, etc all worked, but our app failed. The issue was we call a few endpoints in a row when a number is being assigned. Currently we worked around this by re-initializing the client each time.
Your Environment
On the following lines of code, content-type is set in the http client's
_headerfield during json requests. This causes subsequent requests to break if they rely on a different content-type. For instance, if you callcreate_application(json data) followed byupdate_number(form data) using the same Vonage client, it appears to force it to useapplication/jsonfor the update number call, causing a 420 error.https://github.com/Vonage/vonage-python-sdk/blob/54fa90ddd0508e52f87c9baa775143afc73cb5d9/http_client/src/vonage_http_client/http_client.py#L264C9-L277
Expected Behavior
The
content-typeheader should be set only for the currently running requestCurrent Behavior
The
content-typeheader appears to be sticky, and forces incorrect headers on subsequent requests.Possible Solution
Steps to Reproduce (for bugs)
create_applicationthenupdate_number)Context
We were debugging an issue with a project that was throwing 420s and was difficult to reproduce. Postman requests, curl requests, etc all worked, but our app failed. The issue was we call a few endpoints in a row when a number is being assigned. Currently we worked around this by re-initializing the client each time.
Your Environment