Speedygeek / ZendeskApi_v2

C# wrapper for the Zendesk API
Other
170 stars 200 forks source link

perPage on GetByPageUrlAsync overrides Url parameter and breaks result #568

Closed skartknet closed 1 year ago

skartknet commented 2 years ago

I'm querying Articles with GetArticlesAsync and I'm getting in the results a NextPage like 'https://xxxxx.zendesk.com/api/v2/help_center/en-us/articles.json?page=2&per_page=30

Then I use this URL to query the next page using the GetArticlesByUrlAsync method just like: var response = await _zendeskService.GetArticlesByUrlAsync(response.NextPage);

This by default sets the perPage parameter to 100, when the value on the URL is 30, and the API breaks and doesn't return any items anymore. I reckon the method should check if the parameter already exists on the passed URL and mantain that value.

mozts2005 commented 1 year ago

@skartknet Can you supply a test case to replicate this issue?

mozts2005 commented 1 year ago

@skartknet Looked at the issue more. I think the following test is an example of what you are doing and you will notice the pageSize is a parameter to the GetByPageUrlAsync method the pageSize is optional and defaults to 100 as that is the max allowed.

closing "As Designed" but if you want to submit a PR with overload that using the original page size. I would happily accept it.

https://github.com/Speedygeek/ZendeskApi_v2/blob/430d1bd51285d7e6fa10ce9286e4050dbc887879/tests/ZendeskApi_v2.Tests/HelpCenter/ArticleTests.cs#L213-L223