Closed 0xliam closed 3 months ago
Hi @0xliam, thanks for the PR.
from connectpyse.sales import opportunity_api
o = opportunity_api.OpportunityAPI(url=URL, auth=AUTH, ensure_ascii=True)
Thoughts?
Hi @markciecior, thanks for reviewing! ConnectWise does display these characters correctly when submitted as ASCII, however I agree it might be risky making the change globally - I've done a minimal amount of testing and it doesn't seem to have caused any problems, but I am happy make this a kwarg with the default as the existing behaviour.
I'll rework my PR and submit it later today! :)
Hi @markciecior, I've reworked this PR as suggested - users can now instantiate the API with the ensure_ascii
kwarg, or via the configuration file - and it will default to False, which is the existing behaviour.
Hi @markciecior,
Just wondering if you've had a moment to review this PR? :)
The POST, PUT and PATCH methods do not convert all payloads to ASCII as
ensure_ascii=False
is set on the calls tojson.dumps()
.Currently, if you to send a POST or PATCH request that contains UTF-8 characters to the ConnectWise API, you receive an error.
e.g.
If you set
ensure_ascii=True
, which is the default ofjson.dumps()
, the request is accepted:This PR replaces all usage of
ensure_ascii=False
withensure_ascii=True
.I'm happy to flesh this out a bit more if you want this setting to be controlled by the user.
Note that I am testing against an on-prem instance of ConnectWise (v2024.6.100619).