google-content-api

Google Service Exception ShipmentInfos (Google Orders API)


I'm trying to add tracking data to an order and am getting the following error:

Fatal error: Uncaught exception 'Google_Service_Exception' with message '{ "error": { "errors": [ { "domain": "global", "reason": "invalid", "message": "Invalid value for shipmentInfos: {carrier=ups, shipmentId=A69239235, trackingId=1Z302Y375441956420}", "locationType": "other", "location": "" } ], "code": 400, "message": "Invalid value for shipmentInfos: {carrier=ups, shipmentId=A69239235, trackingId=1Z302Y375441956420}" } } ' in /var/www/html/ta2/gsa/vendor/google/apiclient/src/Google/Http/REST.php:118 Stack trace: #0 /var/www/html/ta2/gsa/vendor/google/apiclient/src/Google/Http/REST.php(94): Google_Http_REST::decodeHttpResponse(Object(GuzzleHttp\Psr7\Response), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #1 [internal function]: Google_Http_REST::doExecute(Object(GuzzleHttp\Client), Object(GuzzleHttp\Psr7\Request), 'Google_Service_...') #2 /var/www/html/ta2/gsa/vendor/google/apiclient/src/Google/Task/Runner.php(176): call_user_func_array(Array, Array) #3 /var/www/html/ta2/g in /var/www/html/ta2/gsa/vendor/google/apiclient/src/Google/Http/REST.php on line 118

I've tried submitting other values and continue to get a similar error.

$shipmentInfo = new Google_Service_ShoppingContent_OrdersCustomBatchRequestEntryShipLineItemsShipmentInfo();
$shipId = "A".mt_rand();
$shipmentInfo->setShipmentId("{$shipId}");
$shipmentInfo->setCarrier("ups");
$shipmentInfo->setTrackingId("{$orderRec[$skuRec]}");

Any thoughts on what I'm doing wrong here?

P.S. I changed the tracking number posted here for privacy reasons.


Solution

  • $shipmentInfo needed to be an array.