Getdata value "after" not URL encoded

Open
#560 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
52/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
php
Domain
api

Research direction

Start in src/Zendesk/API/Traits/Utility/Pagination/CbpStrategy.php at line 53 and reproduce the sections iterator request that sends the page[after] cursor. Trace how that value reaches Zendesk\API\HttpClient::get, then verify the cursor is accepted without requiring callers to encode it themselves. Consider the stated compatibility concern around encoding all query parameters.

Written by the indexing model from the issue text.

Description

When trying to do foreach ($zendesk->helpCenter->sections()->iterator() as $section) I get the error

   Zendesk\API\Exceptions\ApiResponseException  Client error: `GET https://<subdomain>.zendesk.com/api/v2/help_center/sections.json?page%5Bsize%5D=100&page%5Bafter%5D=aQQAAAAAAAAAZFh7/mcAAAAAaR13Wko+GAAA` resulted in a `400 Bad Request` response:
{"errors":[{"code":"InvalidPaginationParameter","title":"Invalid cursor"}]}
 [details] {"errors":[{"code":"InvalidPaginationParameter","title":"Invalid cursor"}]}.

If I urlencode the page[after] value I get a working response. Or adding urlencode on this line https://github.com/zendesk/zendesk_api_client_php/blob/a6d5fc39c46c63a79578ed6b47635271c401fb2b/src/Zendesk/API/Traits/Utility/Pagination/CbpStrategy.php#L53.

This is likely a more widespread problem, so might want to look at encoding all query params sent to Zendesk\API\HttpClient::get, but that would be a breaking change since that is a public method.

An entirely different approach would be to use the meta.next value in the response instead of the meta.after value.

Dominant language
PHP
Stars
344
Forks
247
Avg merge
27m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from zendesk/zendesk_api_client_php

All issues in zendesk/zendesk_api_client_php

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.