2

这已经让我发疯了一个多小时。我是 EasyPost 的新手,我正在尝试在我的标签上添加一些自定义文本(在我的特定情况下,它是要放入包裹中的 SKU),但它似乎从来没有工作过。我正在使用来自easypost的官方nuget包,但我猜它是平台独立的。

Shipment shipment = new Shipment() {
    to_address = toAddress,
    from_address = fromAddress,
    parcel = parcel
};

shipment.Create();
var lowestRate = shipment.LowestRate(includeServices: new List<string>() { "First" }, includeCarriers: new List<string>() { "USPS" });

shipment.Buy(lowestRate);

shipment.options.Add("print_custom_1", "this is some sample text");
shipment.options.Add("print_custom_2", "abc");
shipment.options.Add("print_custom_3", "xyz");

shipment.GenerateLabel("pdf");
4

1 回答 1

2

嗯,这很烦人。当你退后一步时,这是有道理的。问题是需要在创建货件之前设置选项。在我看来,这只是一个打印问题(确实如此),但是还有其他选项可以并且确实会影响运输成本,这意味着需要在创建货件时设置该选项。即使在创建之后但在“购买”之前设置选项也不起作用。

请参阅下面的工作代码:

Shipment shipment = new Shipment() {
    to_address = toAddress,
    from_address = fromAddress,
    parcel = parcel
};

//DO THIS BEFORE CREATING!
shipment.options = new Dictionary<string, object>();
shipment.options.Add("print_custom_1", "this is some sample text");
shipment.options.Add("print_custom_2", "abc");
shipment.options.Add("print_custom_3", "xyz");

shipment.Create();
var lowestRate = shipment.LowestRate(includeServices: new List<string>() { "First" }, includeCarriers: new List<string>() { "USPS" });

shipment.Buy(lowestRate);

shipment.GenerateLabel("pdf");
于 2015-07-07T20:21:24.513 回答