Question

Getting Limited Responses via API due to date range

  • 17 March 2023
  • 5 replies
  • 132 views

Userlevel 4
Badge

Does anyone know how to get more records via the PX API? I am somehow only getting a handful of records when I am requesting all records for a specific user on survey reposnses.

 

Example:{{baseUrl}}/v1/survey/responses?filter=date>01-01-2023&filter=identifyId~639295f8-e365-3c62-8e36-7fcc00f6a4f1

This only gives me 3 responses when I know the user has submitted at least seven. 

 

When i try to add a date range, I keep getting a 400 error “exceeded date range190days”. 

 


5 replies

Userlevel 3

I had a similar experience, interested to understand solution.

Userlevel 2
Badge

Hello @JPKelliher 

 

I hope you are doing good. 

 

As per the error message it seems that you are trying to extract the data which is out of date range of 6 months. Could you please try within 6 months date range and share your observations. 

Userlevel 6
Badge +2

 @JPKelliher Thanks for posting to Gainsight Community!

 

The “date” filter is optional for the “SurveyResponse” REST API and, without it, the PX REST API will return all available Survey Response events … that have happened within the last 190 days.  The PX REST API has date range constraints similar to those imposed inside PX application Analytics that limit date range filters to be only up to 6 months at a time.

 

Therefore, to get event data that was recorded before the last 190 days one must use custom “date” filters spanning up to 190 days at a time. 

 

When I quickly reviewed this particular user, I saw similar REST API results even without a “date” filter.  And, I even confirmed these resultsy using the PX User Profile “Activities” section filtered by in app Engagements. 

 

To be clear, the “SurveyResponse” REST API only returns Survey responses (answers), not all VIEWED/COMPLETED Survey events.  If you want to access those events, you should instead be using the “EngagementViewEvents” REST API.  Some sample API calls are shown below for example:

 

Get all NPS survey Engagement events for a specific user:

{{apiUrl}}/v1/events/engagementView?sort=-date&filter=contentType~IN_APP_SURVEY_NPS;identifyId==639295f8-e365-3c62-8e36-7fcc00f6a4f1

 

Get all Multi question survey Engagement events for a specific user:

{{apiUrl}}/v1/events/engagementView?sort=-date&filter=contentType==IN_APP_MULTIPLE_QUESTION_SURVEY;identifyId==639295f8-e365-3c62-8e36-7fcc00f6a4f1

 

Also, the API error message “Exceeded date range190days” for this “SurveyResponse” and “EngagementViewEvents” REST APIs is not always due to date filter issues.  In these cases, it seems to be also be a “catch all” error message … that our PX Product team should resolve … for other issues such as passing multiple “filter” query parameters in the URL which one should avoid.  See examples below:

 

This call returns RESULTS (one “filter” query parameter):

{{apiUrl}}/v1/survey/responses?sort=date&filter=contentType==IN_APP_MULTIPLE_QUESTION_SURVEY;identifyId==639295f8-e365-3c62-8e36-7fcc00f6a4f1

 

This call returns an ERROR (two “filter query parameters, no “date” filtering):

{{apiUrl}}/v1/survey/responses?filter=identifyId==639295f8-e365-3c62-8e36-7fcc00f6a4f1&filter=contentType==IN_APP_MULTIPLE_QUESTION_SURVEY

 

This call returns RESULTS (one “filter” query parameter):

{{apiUrl}}/v1/events/engagementView?filter=contentType==IN_APP_MULTIPLE_QUESTION_SURVEY;identifyId==639295f8-e365-3c62-8e36-7fcc00f6a4f1

 

This call returns an ERROR (two “filter query parameters, no “date” filtering):

{{apiUrl}}/v1/events/engagementView?filter=contentType==IN_APP_MULTIPLE_QUESTION_SURVEY&filter=identifyId==639295f8-e365-3c62-8e36-7fcc00f6a4f1

 

Lastly, if you do know there are at least 7 Survey Responses for this particular user and they are not spread across multiple PX Subscriptions, then it would be best to create a new PX Support request (pxsupport@gainsight.com) for additional review by our team.

 

I hope this helped a little...

Userlevel 4
Badge

@link_black  As usual, you nailed it. Thank you. Can you please clarify this error about the API error message “Exceeded date range190days” ? Is there a limitation on how much information can be queried if a time frame is not in the filter? 

 

I am still finding that I am not receiving all the records unless I break the query up by 190 day segments.

 

Userlevel 6
Badge +2

@JPKelliher

I have just learned/confirmed with our PX Engineering team that by default our PX REST API will only return up to the last ~6 months worth of event data for any given request (~190 days).  And, one can only use custom “date” filters spanning up to 190 days at a time. 

 

So, when a custom date range is exceeded in the REST API call, then the “Exceeded date range190days” error message will be correctly displayed.  The PX REST API has date range constraints similar to those imposed inside PX application Analytics that limit date range filters to be only up to 6 months at a time.

 

So, to get all the historic event data like you are trying to do (greater than 190 days ago), then one would need to call the REST APIs multiple times with custom date ranges in 190 day blocks … unless you are only concerned about extracting/analyzing the last ~6 months worth of event data (~190 days) that will be included in the default REST API results without any “date” filters applied.

 

I do need to update my post above with these new findings to be more accurate, thank you for the followup.

Reply