scenario
A recent requirement for the goods department related to the API for shipping and warehousing was investigated in the fulfillment- inbound-API
Official document path: fulfillment-inbound-api
Specific steps learned from the goods department are:
-
Create a plan for the shipment (createInboundShipmentPlan)
-
Then create createInboundShipment,
-
Finally get getLabels
With that in mind, I tried the following
In field
The preparatory work
- Amazon Store Account
- Developer permissions if you do not build a developer environment please click here
- Configure AWS authentication. If you do not know how to configure AWS authentication, click here to invoke SP-API
First, get the relevant information about the shipment
1. Obtain the shipment that has been created –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());
Copy the code
The obtained results are as follows:
2. Get the pasting list that has been created for shipment –getLabels
Note: pageSize=5 means to ask the goods for a certain shipmentId in advance. There are altogether five packing lists for this shipment.
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());
Copy the code
The obtained results are as follows:
Once you have the information you acquired in the first step, you plan to explore the entire process.
Second, complete process
createInboundShipmentPlan–>createInboundShipment–>getLabels
Create – createInboundShipmentPlan Java
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());
}
Copy the code
An error 400 was reported after the request was initiated, indicating that the request was failed.
Note: After carefully checking the parameters, try again and still fail, switch to Python and send the request with the same parameters successfully. Because the author’s level is limited, temporarily can’t solve this problem. The final post-packing list obtained by Python is as follows:
With the first step to obtain the sticker list is not the same, but also do not know throughfulfillment-inbound-apiHow to specify LCL operation.Hope that there are leaders who have studied this part to point out the mistakes, but also welcome everyone to exchange and learn from each other.
PS: If you think it is helpful to you, you can leave a message in three consecutive times. Welcome to put forward your valuable opinions. If you want to have technical exchanges, you are welcome to join the Amazon API development Communication Group! Please add technical personnel on wechat:x118422Invite into the group