EasyPost/easypost-php

Problem adding CustomsInfo to existing Shipment

Closed this issue · 2 comments

I am getting The requested resource could not be found. when attempting to load a shipment and add customs info. V3.4.0

Is this order of process not possible or is there an issue here that needs resolving?

Example:

        $shipment    = \EasyPost\Shipment::retrieve( $shipment_id );
	$customs_info = \EasyPost\CustomsInfo::create($customs_info_params);
	$customs_info->save();
	$shipment->__set('customs_info', $customs_info);
	$shipment->save();

The resource not found error is thrown on $shipment->save();

The shipment is retrieved, I can access the data and use the object. A dump of the shipment obj before save appears to show a valid object with the newly created customs info attached, all ID's present. Whats going wrong here?

The issue occurs when the Shipment attempts to send a PATCH to /shipments

EasypostResource::__save():
list($response, $apiKey) = $requestor->request('patch', $url, $params);

Server is returning 404
{"error":{"code":"NOT_FOUND","message":"The requested resource could not be found.","errors":[]}}

GET and POST methods for the same shipment ID work as expected.

Does easypost not allow you to update/patch shipments?

Use case where update/patch on shipments is required:
User needs to create a shipment to fetch available carriers and rates. The desired carrier and rate is selected, the shipment is saved but not yet purchased. A separate session requests the shipment by ID, adds required customs info to the shipment before buying the shipment/label for dispatch.

Shipment objects are immutable and can not be modified after creation with the exception of purchasing a label. If you need to add customs information to a shipment you will need to create a new shipment. Please send questions like this to support@easypost.com.