conjure-python icon indicating copy to clipboard operation
conjure-python copied to clipboard

Path parameters are not url encoded

Open ktekelioglu opened this issue 3 years ago • 0 comments

What happened?

This was discovered in the palantir-python-sdk library: https://github.com/palantir/palantir-python-sdk/issues/20

Python classes generated by this library have a bug when a special character is encountered in a path parameter. The example in the above issue is a branch parameter with a '/' character.

What did you want to happen?

Path parameters should be url encoded. It can be done with a simple utility function as such:

def format_path_with_params(path, path_params):
    escaped_path_params = {
        k: requests.utils.quote(v, safe="") for k, v in path_params.items()
    }
    return path.format(**escaped_path_params)

ktekelioglu avatar Aug 03 '22 09:08 ktekelioglu