jpetrucciani / hubspot3

python3.6+ hubspot client based on hapipy, but modified to use the newer endpoints and non-legacy python
MIT License
147 stars 73 forks source link

Only convert request payloads to JSON a single time #51

Closed sangaline closed 5 years ago

sangaline commented 5 years ago

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.

jpetrucciani commented 5 years ago

Oh good catch! Thanks for the fix - I'll try to get a new release out today!

jpetrucciani commented 5 years ago

This is now live on pip as version3.2.22!

Thanks again for the fix! 😄