0

I'm trying to write a simple python program that uses admin-sdk (Google Directory API) to search for all users within a certain OU. The problem I encounter is that there is a space character in one of the containers and my code breaks down at this point. I am certain that that space is the problem. How to escape the space character or is there another solution?

Here is the code that causes the problem:

results = service.users().list(query='orgUnitPath=/local/example/IAM Users',customer='my_customer', maxResults=500,orderBy='email').execute()   

If I change this to the following, then it works fine. It only breaks at the space in the "IAM Users" container:

results = service.users().list(query='orgUnitPath=/local/example',customer='my_customer', maxResults=500,orderBy='email').execute() 

Thanks!

James Jones
  • 3,850
  • 5
  • 25
  • 44
M Azim
  • 11
  • 2
  • The error I get is this: ...raise HttpError(resp, content, uri=self.uri) googleapiclient.errors.HttpError: – M Azim Feb 04 '19 at 09:21

1 Answers1

1

Solution:

results = service.users().list(query="orgUnitPath='/local/example/IAM Users'",
                               customer='my_customer',
                               maxResults=500,
                               orderBy='email').execute() 
snakecharmerb
  • 47,570
  • 11
  • 100
  • 153
M Azim
  • 11
  • 2