EasyPost API - print_custom_1 选项不会打印在标签上
EasyPost API - print_custom_1 option won't print on label
这让我发疯了一个多小时。我是 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");
嗯,这很烦人。当您退后一步时,这是有道理的。问题是需要设置选项 PRIOR 以创建货件。在我看来,这只是一个打印问题(确实如此),但还有其他选项可以并且确实会影响运输成本,这意味着需要在创建装运时设置该选项。即使在创建之后但在创建之前设置选项 "buy" 也不起作用。
查看下面的工作代码:
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");
这让我发疯了一个多小时。我是 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");
嗯,这很烦人。当您退后一步时,这是有道理的。问题是需要设置选项 PRIOR 以创建货件。在我看来,这只是一个打印问题(确实如此),但还有其他选项可以并且确实会影响运输成本,这意味着需要在创建装运时设置该选项。即使在创建之后但在创建之前设置选项 "buy" 也不起作用。
查看下面的工作代码:
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");