Repository navigation
Description
Software Version
6.7.2 (key unchanged on master)
Language Version
.NET 10 (library target net8.0)
Operating System
Windows 11 and Linux (not OS-specific)
What happened?
Parameters.Shipment.Buy.EndShipperId is serialized under the key end_shipper, but the API only honours end_shipper_id, so the EndShipper is silently ignored.
- Create a shipment and pick a USPS rate from EasyPost's default USPS account.
- Create an EndShipper (
client.EndShipper.Create(...)) with a complete address (name, company, street1, city, state, zip, country, phone, email). - Buy with
client.Shipment.Buy(shipmentId, new Parameters.Shipment.Buy(rate) { EndShipperId = endShipper.Id }). - The buy fails with
BAD_REQUEST:ProviderEndShipper address.name or address.company required.
Sending the same request body with end_shipper_id instead of end_shipper (raw HTTP, same shipment, rate and EndShipper) buys the label successfully. Reproduced every time in test mode.
Cause: EasyPost/Parameters/Shipment/Buy.cs declares [TopLevelRequestParameter(Necessity.Optional, "end_shipper")] on EndShipperId, and the string overload in Services/ShipmentService.cs does parameters.Add("end_shipper", endShipperId). Both are still like this on master. The EndShipper guide (https://docs.easypost.com/guides/endshipper-guide) documents the top-level end_shipper_id key, and the Python client sends end_shipper_id.
What was expected?
EndShipperId is sent as end_shipper_id, and the USPS label is purchased with that EndShipper.
Sample Code
var endShipper = await client.EndShipper.Create(new EasyPost.Parameters.EndShipper.Create
{
Name = "Jane Doe", Company = "Example Co", Street1 = "417 Montgomery Street", City = "San Francisco",
State = "CA", Zip = "94104", Country = "US", Phone = "4153334445", Email = "shipping@example.com"
});
var buy = new EasyPost.Parameters.Shipment.Buy(uspsRate) { EndShipperId = endShipper.Id };
buy.ToDictionary(); // contains "end_shipper", not "end_shipper_id"
await client.Shipment.Buy(shipment.Id, buy); // ApiError: ProviderEndShipper address.name or address.company required
// Workaround we use:
public class FixedBuy : EasyPost.Parameters.Shipment.Buy
{
public FixedBuy(Rate rate) : base(rate) { }
public override Dictionary<string, object> ToDictionary()
{
var d = base.ToDictionary();
if (d.Remove("end_shipper", out var id)) d["end_shipper_id"] = id;
return d;
}
}Relevant logs
{"error":{"code":"BAD_REQUEST","message":"The request could not be understood by the server due to malformed syntax.","errors":[{"message":"ProviderEndShipper address.name or address.company required"}]}}
Activity
fix: end_shipper_id param (#670)
fix: end_shipper_id param (#670)
chore: prep v7.11.0 for release (#672)