I would like to share a survey via an API call (as documented here: https://api.qualtrics.com/reference#share-survey) , 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 (https://api.qualtrics.com/reference#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}.qualtrics.com/API/v3/directories".format(self.dataCenter),headers=headers)
directoryId = tmp.json()['result']['elements'][0]['directoryId']
sharewith='XXXX@XXXX.com'
filterstr = """
{
"filterType": "email",
"comparison": "eq",
"value": "%s"
}"""%sharewith
filterjson = json.loads(filterstr)
data = {"filter":filterjson}
tmp = requests.post("https://{0}.qualtrics.com/API/v3/directories/{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: akka.util.ByteIterator$ByteArrayIterator$$anon$1@5720ef32; line: 1, column: 8]"
Page 1 / 1
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?
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.