场景
最近要做货品部门的需要,波及到发货和入库相干的 API,对此钻研了fulfillment-inbound-api
官网文档门路:fulfillment-inbound-api
从货品部门理解到的具体步骤为:
- 创立一个发货打算(createInboundShipmentPlan)
- 而后创立发货(createInboundShipment),
- 最初获取贴箱单(getLabels)
再理解到这些后我做了如下尝试
实操
筹备工作
- 亚马逊店铺账号
- 开发者权限 如不会搭建开发者环境请点这里
- 配置 AWS 认证 如不会配置 AWS 认证请点这里,实现 6 以前的操作就能够调用 sp-api 了
第一、获取已经发货的相干信息
1. 先获取已经创立过的发货 -getShipments
String queryType="SHIPMENT";
String marketplaceId = "ATVPDKIKX0DER";
GetShipmentsResponse shipments = null;
List<String> shipmentStatusList = Arrays.asList("WORKING","SHIPPED","RECEIVING","CANCELLED","DELETED","CLOSED","ERROR","IN_TRANSIT","DELIVERED","CHECKED_IN");
ArrayList<String> shipmentIdList = new ArrayList<>();
try {shipments = fbaInboundApi.getShipments(queryType,marketplaceId,shipmentStatusList,shipme ntIdList,start_time,end_time,null);
} catch (ApiException e) {e.printStackTrace();
}
GetShipmentsResult payload = shipments.getPayload();
System.out.println("payload.getShipmentData() =" + payload.getShipmentData());
获取的后果如下:
2. 获取已经创立过发货的贴箱单 -getLabels
留神:pageSize= 5 是当时向货品询问好某个 shipmentId 本次发货一共五个贴箱单。
GetLabelsResponse labels = null;
try {labels = fbaInboundApi.getLabels("shipmentId", "PackageLabel_Letter_2", "BARCODE_2D", null, null, null, 5, null);
} catch (ApiException e) {e.printStackTrace();
}
System.out.println("DownloadURL =" + labels.getPayload().getDownloadURL());
获取的后果如下:
在有了第一步获取的信息之后,打算着手钻研整套流程。
第二、残缺流程
createInboundShipmentPlan–>createInboundShipment–>getLabels
Java 创立 -createInboundShipmentPlan
CreateInboundShipmentPlanRequest body = new CreateInboundShipmentPlanRequest();
Address address = new Address();
address.setName("your shop");
address.setAddressLine1("your address");
address.setDistrictOrCounty("your districtOrCounty");
address.setCity("your city");
address.setStateOrProvinceCode("your stateOrProvinceCode");
address.setCountryCode("your countryCode");
address.setPostalCode("your postalCode");
body.setShipFromAddress(address);
body.setLabelPrepPreference(LabelPrepPreference.SELLER_LABEL);
body.setShipToCountryCode("US");
body.setShipToCountrySubdivisionCode("US-CA");
InboundShipmentPlanRequestItemList list = new InboundShipmentPlanRequestItemList();
InboundShipmentPlanRequestItem inboundShipmentPlanRequestItem = new InboundShipmentPlanRequestItem();
inboundShipmentPlanRequestItem.setASIN("your asin");
inboundShipmentPlanRequestItem.setSellerSKU("your seller sku");
inboundShipmentPlanRequestItem.setCondition(Condition.NEWITEM);
inboundShipmentPlanRequestItem.setQuantity(1);
inboundShipmentPlanRequestItem.setQuantityInCase(1);
PrepDetailsList prepDetails = new PrepDetailsList();
PrepDetails details = new PrepDetails();
details.setPrepInstruction(PrepInstruction.LABELING);
details.setPrepOwner(PrepOwner.SELLER);
prepDetails.add(details);
inboundShipmentPlanRequestItem.setPrepDetailsList(prepDetails);
list.add(inboundShipmentPlanRequestItem);
body.setInboundShipmentPlanRequestItems(list);
CreateInboundShipmentPlanResponse shipmentPlan = null;
System.out.println("body =" + body);
try {shipmentPlan = fbaInboundApi.createInboundShipmentPlan(body);
} catch (ApiException e) {e.printStackTrace();
} finally {System.out.println("shipmentPlan.getErrors() =" + shipmentPlan.getErrors());
System.out.println("shipmentPlan.getPayload() =" + shipmentPlan.getPayload());
}
发动申请之后报错 400,申请未通过。
注:在仔细检查完参数之后再次尝试还是失败,转战 python 之后雷同的参数发送申请胜利。因为笔者程度无限,一时没法解决这个问题。通过 python 最终获取到的贴箱单如下: