Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined array key 3 on getProfiles endpoint when using more than 3 arguments #44

Open
HappydaysAS opened this issue Feb 16, 2024 · 3 comments

Comments

@HappydaysAS
Copy link

HappydaysAS commented Feb 16, 2024

I have the following line of code

$response = $this->klaviyoAPI->Profiles->getProfiles(filter: $filter, apiKey: config('klaviyo.api_token'), page_cursor: $pageCursor, page_size: $pageSize);

This give me the following error

   ErrorException 

  Undefined array key 3

  at vendor/klaviyo/api/lib/Subclient.php:47
     43▕             $param_position = $param->getPosition();
     44▕ 
     45▕             if (count($args) > $param_position) {
     46▕ 
  ➜  47▕                 $page_cursor = $args[$param_position];
     48▕                 if ($page_cursor != NULL) {
     49▕                     $page_cursor = $this->new_page_cursor($page_cursor);
     50▕ 
     51▕                     $args[$param_position] = $page_cursor;

If I reduce the amount of arguments to 3, it works correctly. Also, by stepping through the code above, I notice that the $args array in line 47 does indeed not have numbered keys, but named keys, which is why it fails.

@HappydaysAS HappydaysAS changed the title Undefined array key 3 on getProfiles endpoint when using page_size Undefined array key 3 on getProfiles endpoint when using more than 3 arguments Feb 16, 2024
@sanfordj
Copy link

thank you for bringing this to our attention! we will take a look.

@jon-batscha
Copy link
Collaborator

I believe the issue is that you are using page_cursor with page_size. I don't believe you can use both at the same time (as page_cursor encodes a fixed page_size from the initial query.

I will look into this further to see if I find anything else to share.

@sc0ttkclark
Copy link

This is because the Subclient logic here in __call() does not properly support named arguments.

See my PR for a proper fix for this: #50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants