Forum Discussion

Vikas2022's avatar
Vikas2022
New Contributor II
3 years ago

Pagination in REST GET API for UserVoice not giving expected results

Hello,

In Snaplogic I have established a connection with UserVoice rest API via Bearer token and I am also able to fetch data from the first iteration.

There are no errors, But unfortunately, I am not able to get data for the next iterations(pagination). I have used the Has next and Next URL properties of REST GET Snap for this.

JSON API response which I get from 1st iteration:

{
	"categories": [
		{
			"id": 426064,
			"name": "Dashboards",
			"suggestions_count": 2,
			"open_suggestions_count": 0,
			"created_at": "2022-04-27T13:42:03Z",
			"updated_at": "2022-06-27T14:49:53Z",
			"links": {
				"forum": 942688
			}
		},
		{
			"id": 403581,
			"name": "Data Integrity - Generic",
			"suggestions_count": 6,
			"open_suggestions_count": 3,
			"created_at": "2021-04-28T10:01:31Z",
			"updated_at": "2022-06-07T01:27:28Z",
			"links": {
				"forum": 933466
			}
		}
	],
	"links": {
		"categories.forum": {
			"type": "forums"
		}
	},
	"list_meta": null,
	"pagination": {
		"page": 1,
		"per_page": 20,
		"total_pages": 4,
		"total_records": 61,
		"cursor": "eyJzb3J0IjoiIiwidmFsIjpudWxsLCJsYXN0X2lkIjo0MDM1ODF9"
	}
}

Since I want to paginate until I get the cursor in response, so I am using the below setting in REST GET Snap

For reference, pagination in PostMan is working as expected.

Can someone, please help me in getting records in pagination?

Thanks.

1 Reply

  • chenry's avatar
    chenry
    Former Employee

    Hi there,

    Looks like you’re attempting to put all possible subcategory selections into one drop down menu, and then hide certain ones. That could get tricky. You may want to do something more UI-tricky, and create two sub category drop down lists. One with animals, and one with cars. The default subcategory can be shown, if you default the main category to say…animals, and then if you make the main category selection, you can hide/unhide the other drop downs accordingly. That may do the trick, but then you have to be careful in your handling code, to key on the enums that you pull out of the subcategory based on the main category. I think the trickiest part here would be the hiding and unhiding of fields.

    Make sure that if you go this route, that both dropdown menus are the same size and placement, otherwise the UI might look meh, if you have components on the Snap popping in and out of view, and skewing the placement of other UI components.
    Thanks,
    -Charlie