Retrieve an individual survey link from a distribution | XM Community
Skip to main content

Is it possible to pass an id or something to retrieve a single survey link using the API? I would rather not have to go through multiple pages to search for one if my distribution contains thousands of contacts.

Hi mroyski,
The closest call to what you're after still lists all the links for a specific distribution ID. It does return information about each link though (contact ID, external data reference etc). Perhaps you could search one of those to find the specific link you're after?
Good luck!


bgooldfed, for the response from that request is the page limit 100?


https://community.qualtrics.com/XMcommunity/discussion/comment/49434#Comment_49434The result returns a string nextPage, which will contain the URL to the next 100 (or fewer) results. If there are no further results it will be null.
So just loop through the API call, check nextPage exists and if it does run another request.
Rough Python example (untested):
# # # # # # # # # # # # # # # # # # # # # # # #
# # # set your url and headers here first # # #
# # # # # # # # # # # # # # # # # # # # # # # #

response = requests.get(baseUrl, headers=headers)
# prepare response as a JSON file
myJson = response.json() 'result']e'elements']
# create an empty list to add whatever you want. You can use a dictionary if you require key:value pairs instead.
myList = t]

# iterate through element and append to list
for i in myJson:
   myList.append(i'link'])

#subsequent pages
nextPage = response.json()g'result']n'nextPage']
while(nextPage):
    nextResponse = requests.get(nextPage, headers=headers)
    nextJson = nextResponse.json()o'result']e'elements']
    nextPage = nextResponse.json()P'result']t'nextPage']
    print(nextPage)
    for i in nextJson:
        myList.append(io'link'])
After that, just search through your created list/dictionary/array/whatever to find your desired link.
Good luck!


Leave a Reply