Get Surveys Every 30 Minutes | XM Community
Solved

Get Surveys Every 30 Minutes

  • 20 September 2018
  • 5 replies
  • 5 views

I'm using API v3.0 to get survey responses. If I set the start/end times to pull data every 30 minutes it doesn't grab surveys in taht time frame, but if I set start/end times to pull every 24 hours that works leading me to believe that the API is ignoring the time portion of this parameter if its within the same day. Is that correct or is something wrong with my date/time parameters?
icon

Best answer by RKT 20 September 2018, 17:03

View original

5 replies

Userlevel 2
Badge +1
@ralbritton ,

Response Export ID Caching
A Response export ID is valid for one week. If consecutive Create Response Export calls are run with the same parameters, the call will return the same export ID. There are a few ways to get around this.

1) You can pass in the "seenUnansweredRecode" parameter and pass in a random number value.

2) You can set an "endDate" that is well in the future and choose different dates to send a new request.

Link
Thanks @RKY - I need to automate this so it may be easiest to do the first option. When you say, "pass in a random number value" I'm assuming that every 30 minutes when the code runs, this value will need to be a new random number each time. Is that correct?
Userlevel 2
Badge +1
> @ralbritton said:
> Thanks @RKY - I need to automate this so it may be easiest to do the first option. When you say, "pass in a random number value" I'm assuming that every 30 minutes when the code runs, this value will need to be a new random number each time. Is that correct?

Of course random number will new
@RKY - I tried your suggestion and still am not receiving a dataResponse back. Am I miss understanding something?

downloadRequestUrl = baseUrl
downloadRequestPayload = {"format":fileFormat,"surveyId": surveyId, "useLabels": True, "startDate": str(startTimeISO) + 'Z', "endDate": str(endTimeISO) + 'Z', "seenUnansweredRecode":(str(randint(0, 9)))}
downloadRequestResponse = requests.request("POST", downloadRequestUrl, data=json.dumps(downloadRequestPayload), headers=headers)
print downloadRequestResponse.json()
progressId = downloadRequestResponse.json()["result"]["id"]
@RKY - after playing around with this it does appear that hard coding in a very distant future date does allow me to pull data in the past 30 minutes. I could not get the random # suggestion to work though (for anyone else looking for a solution).
Thank you.

Leave a Reply