google-api-python-client icon indicating copy to clipboard operation
google-api-python-client copied to clipboard

Org Units with + and # in their names can not be gotten

Open taers232c opened this issue 9 months ago • 0 comments

GAM is using the Google API Python client and making calls like this: cd is the Directory service object.

      result = callGAPI(cd.orgunits(), 'get',                                                                                                                                                        
                        customerId=GC.Values[GC.CUSTOMER_ID], orgUnitPath=orgUnitPath)                                                                                            

If the orgUnitPath contains + or #, the URL is not correct.

1: Get OU "Test/Test % Percent"
send: b'GET /admin/directory/v1/customer/my_customer/orgunits/Test/Test%20%25%20Percent?prettyPrint=true&alt=json HTTP/1.1\r\nHost: admin.googleapis.com\r\naccept: application/json\r\naccept-encoding: gzip, deflate\r\nuser-agent: GAM 7.05.08 - https://github.com/GAM-team/GAM / GAM Team <[email protected]> / Python 3.13.2 final / macOS-15.3.2-arm64-arm-64bit-Mach-O arm64 / (gzip)\r\nx-goog-api-client: gdcl/2.164.0 gl-python/3.13.2 cred-type/u\r\ncontent-length: 0\r\nauthorization: Bearer ya29.xxx\r\n\r\n'
reply: 'HTTP/1.1 200 OK\r\n'

Works

2: Get OU "Test/Test + Plus"
send: b'GET /admin/directory/v1/customer/C03pmm8ne/orgunits/Test/Test%20+%20Plus?prettyPrint=true&alt=json HTTP/1.1\r\nHost: admin.googleapis.com\r\naccept: application/json\r\naccept-encoding: gzip, deflate\r\nuser-agent: GAM 7.05.08 - https://github.com/GAM-team/GAM / GAM Team <[email protected]> / Python 3.13.2 final / macOS-15.3.2-arm64-arm-64bit-Mach-O arm64 / (gzip)\r\nx-goog-api-client: gdcl/2.164.0 gl-python/3.13.2 cred-type/u\r\ncontent-length: 0\r\nauthorization: Bearer ya29.xxx\r\n\r\n'
reply: 'HTTP/1.1 404 Not Found\r\n'

Fails, + was not URL encoded, it should be 'Test%20%2B%20Plus'

3: Get OU "Test/Test # Sharp"
send: b'GET /admin/directory/v1/customer/my_customer/orgunits/Test/Test%20 HTTP/1.1\r\nHost: admin.googleapis.com\r\naccept: application/json\r\naccept-encoding: gzip, deflate\r\nuser-agent: GAM 7.05.08 - https://github.com/GAM-team/GAM / GAM Team <[email protected]> / Python 3.13.2 final / macOS-15.3.2-arm64-arm-64bit-Mach-O arm64 / (gzip)\r\nx-goog-api-client: gdcl/2.164.0 gl-python/3.13.2 cred-type/u\r\ncontent-length: 0\r\nauthorization: Bearer ya29.xxx\r\n\r\n'
reply: 'HTTP/1.1 404 Not Found\r\n'

Fails, '%23%20Sharp?prettyPrint=true&alt=json' is all missing before HTTP

taers232c avatar Mar 13 '25 03:03 taers232c