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
DealsTimeline mapping error: JsonMapper::map requires first argument to be an object, array given. #52
Comments
Note the above is for package version 1.01. I get similar errors in 3.2 but the line numbers are different. InvalidArgumentException apimatic/jsonmapper/src/JsonMapper.php:103 |
I believe I've found a solution for this that's a very simple change in the GetDealsTimeline model to indicate that the data is an array of Data25 objects, not just a single Data25 object.
I opened a pull request for this change (see above) |
Hi! |
InvalidArgumentException
JsonMapper::map() requires first argument to be an object, array given.
in vendor/apimatic/jsonmapper/src/JsonMapper.php:103
It looks like the getDealsTimeline API response returns an object with the data member as an array for like this:
When jsonmapper tries to map this response in
pipedrive/pipedrive/src/Controllers/DealsController.php:459
the data ends up being recognized as an object of type\Pipedrive\Models\Data25
rather than as an array. But inapimapper/jsonmapper/src/JsonMapper.php:103
an InvalidArgumentException is thrown because$json
that is passed in is an array rather than an object.Ultimately, I think JsonMapper should be calling
mapArray
ormapClassArray
aroundJsonMapper.php:247
but it is instead trying to callmap
which only works with an object.I wish I could have determined the root cause here to provide a merge request to fix this, but the best I could come up with is to skip using JsonMapper and to instead just return the object that comes back from the API. This looks like:
That solution neglects whatever value JsonMapper has.
Thanks for your help troubleshooting and fixing this issue!
The text was updated successfully, but these errors were encountered: