Address formatting issue in request when street address is empty
I was receiving issues of a "malformatted" request error when requesting shipping methods using only the postal code from the following method:
\ShipperHQ\Shipper\Model\Carrier\Shipper::setRequest()
The error I received:
Could not read document: Can not deserialize instance of java.lang.String out of START_ARRAY token
The error while in debug mode:
Malformed Request. The request was not formed correctly.
I was able to trace the issue down to the destination address being passed in the request. The issue was that the destination street passed from the quote address was an empty array.
To mediate the issue, I created an event to observe the shipperhq_carrier_set_request event and turn the destination street into a string.
public function execute(Observer $observer)
{
$request = $observer->getData('request');
if (is_array($request->getDestStreet())) {
$request->setDestStreet(implode(' ', $request->getDestStreet()));
}
}
The observer works, but not sure if you have a better idea?
Thanks!
Hi - thanks for the contribution. We are currently looking at this. Could you let me know what version of Magento you are running?
I am currently on Magento 2.1.9
Hi - This was addressed in the latest version of the extension, 20.12.0. Updating to that version should resolve.
Great, thank you!