Share survey and find userid via API

dsavranskydsavransky Community Member Qubie ✭

Share survey and find userid via API

I would like to share a survey via an API call (as documented here: , but I'm having trouble getting the userid of the user to share with. When I do this manually via the web interface I search for the user by email, so I thought I could use the directory contacts search (, but can't get it to work at all.

(Python) code is:
headers = {
"x-api-token": self.apiToken,
"content-type": "application/json",
"Accept": "application/json"

tmp = requests.get("https://{0}".format(self.dataCenter),headers=headers)
directoryId = tmp.json()['result']['elements'][0]['directoryId']

sharewith='[email protected]'

filterstr = """
"filterType": "email",
"comparison": "eq",
"value": "%s"
filterjson = json.loads(filterstr)
data = {"filter":filterjson}

tmp ="https://{0}{1}/contacts/search".format(self.dataCenter,directoryId),headers=headers,data=data)

I get back error: "Error decoding json body: com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'filter': was expecting 'null', 'true', 'false' or NaN\n at [Source: [email protected]; line: 1, column: 8]"



  • dsavranskydsavransky Community Member Qubie ✭

    Ok, so I just had a stupid syntax error, but once that was fixed, I'm getting an access permissions error, so apparently I can't do any searches via the API? Any other way of searching for the userid by email?

Sign In to Comment