This repository has been archived by the owner on Sep 29, 2023. It is now read-only.
Re-Order the array keys so that JSON will be an array, not an object #1034
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SDK/Library version: 1.13.0
Environment: Sandbox
PayPal-Debug-ID values: 3a5fd0a7adf56
I have create an Item array along these lines:
Which returns this error from the API:
Here is the generated JSON:
Not that "items" is not an array here, but an object - the only difference to working requests.
As the SDK only requires to submit an array, not an "array numbered from 0..N" (e.g. it also could be an associative array), I suggest using
array_values
as in this pull request. Probably this should be added at other places of the API as well for consistency.This kind of error could also appear when using "ItemList->removeItem", as array_diff also doesn't re-order the keys (see unit test).
The Unit test failed at the beginning because setItems is given
Item
instead ofarray(Item)
, is this a legacy/compability usage?