The BaseClient._call_raw() method currently catches HubspotUnauthorized errors, and then recursively calls itself after refreshing the OAuth2 tokens. This results in BaseClient._prepare_request() being called a second time which results in json.dumps() being called on the data payload twice. A payload like {"a": 1} then becomes "{\"a\":1}" and the Hubspot API can't successfully parse the content.
This PR passes the retried parameter into BaseClient._prepare_request() and skips the json.dumps() step for requests that are being retried.
The
BaseClient._call_raw()
method currently catchesHubspotUnauthorized
errors, and then recursively calls itself after refreshing the OAuth2 tokens. This results inBaseClient._prepare_request()
being called a second time which results injson.dumps()
being called on the data payload twice. A payload like{"a": 1}
then becomes"{\"a\":1}"
and the Hubspot API can't successfully parse the content.This PR passes the
retried
parameter intoBaseClient._prepare_request()
and skips thejson.dumps()
step for requests that are being retried.