openapi-python-sdk icon indicating copy to clipboard operation
openapi-python-sdk copied to clipboard

Query parameters not properly URL-encoded (pandas data pipeline)

Open francescobianco opened this issue 8 months ago • 7 comments

Query parameters not properly URL-encoded (pandas data pipeline)

Description
Special characters break API calls when used in data pipelines.

Code snippet

params = {
    "denominazione": "azienda & co"
}

response = client.request(
    "GET",
    base_url,
    "/advance",
    params=params
)

Observed behavior
400 Bad Request due to invalid encoding.

francescobianco avatar Mar 18 '26 14:03 francescobianco

I think the root cause here might be related to the client.request method, which is using the params dictionary directly without URL-encoding the query parameters. IIRC, the requests library (which is likely being used under the hood) expects the query parameters to be passed as a dict with the keys being the parameter names and the values being the parameter values. However, it does not automatically URL-encode the values. You might want to try using the urllib.parse.urlencode function to encode the params dictionary before passing it to the client.request method.

IlyasFardaouix avatar Mar 19 '26 04:03 IlyasFardaouix

Good point, thanks @IlyasFardaouix for looking into it.

We’re currently experimenting with a slightly different approach using Pandas for handling responses, so this area is still evolving on our side.

Any suggestions or experiments around improving the decoding/handling flow are more than welcome — feel free to share ideas or even open follow-up PRs.

francescobianco avatar Mar 24 '26 10:03 francescobianco

Hey @francescobianco ,

I just raised a PR #16 fixing this bug.

Check, Verify and Let me know!

Deadpool2000 avatar Apr 05 '26 10:04 Deadpool2000

Great work @Deadpool2000, thanks for the PR! 🙌

Even though this seems to fix the issue, we’ll keep it open for now so we can run some internal tests in our environment over the next few months.

Once everything is fully verified and confirmed as stable, we’ll proceed with closing the issue.

Thanks again for your collaboration!

francescobianco avatar Apr 14 '26 10:04 francescobianco

@francescobianco Thanks 😊

Deadpool2000 avatar Apr 15 '26 16:04 Deadpool2000

Thanks @Deadpool2000 now you are mentioned here https://github.com/openapi/openapi-python-sdk/releases/tag/0.3.0

francescobianco avatar May 12 '26 08:05 francescobianco

@francescobianco thanks for the mention, happy to see it all make it into the release 😊

Deadpool2000 avatar May 12 '26 17:05 Deadpool2000