Closed joevu-stlpro closed 3 years ago
@joevu-stlpro https://github.com/amzn/selling-partner-api-models/issues/1746
Hope it helps.
thanks @chenlixin93 however, when I tried the api version 2021-06-30, for the api Create Feed Document, the response does not contain the key encryptionDetails
(only 2 keys feedDocumentId
and url
) in order to encrypt file on uploading, then it fails to upload feed content to the feed document.
While the old version 2020-09-04 does contain the field encryptionDetails
.
To be honest, the document is inconsistent and 100% cover all needed materials for SELLERs.
I am also looking for the feed type request/response POST_FLAT_FILE_INVLOADER_DATA
, however, there is no specification (no .xsd
file) in this feedtype-values document
@joevu-stlpro
about encrypt file( https://github.com/amzn/selling-partner-api-docs/discussions/1107 ) :
We've been listening to your feedback and are removing the requirement for client-side encryption for Selling Partner API (SP-API) Feeds and Reports APIs.
about only 2 keys : https://github.com/amzn/selling-partner-api-docs/blob/main/references/feeds-api/feeds_2021-06-30.md#createfeeddocumentresponse
about POST_FLAT_FILE_INVLOADER_DATA :
I have not used this template, you can just google POST_FLAT_FILE_INVLOADER_DATA template
to find the answer.
https://stackoverflow.com/questions/39289735/amazon-mws-api-submitfeed-post-flat-file-invloader-data-incorrect-template-typ
As I konw, SP-API use the same xml format as MWS.
Thanks a ton @chenlixin93
I have resolved my problem, just wanna share how it works in both versions.
I use the python package: https://github.com/saleweaver/python-amazon-sp-api/
I install the package python-amazon-sp-api, and use the old MWS feed message
<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope xsi:noNamespaceSchemaLocation="amzn-envelope.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>None</MerchantIdentifier>
</Header>
<MessageType>OrderFulfillment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderFulfillment>
<AmazonOrderID>--------</AmazonOrderID>
<FulfillmentDate>2021-08-20T02:35:31.312036+00:00</FulfillmentDate>
<FulfillmentData>
<CarrierCode>--------</CarrierCode>
<ShippingMethod>--------</ShippingMethod>
<ShipperTrackingNumber>--------</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<AmazonOrderItemCode>--------</AmazonOrderItemCode>
<Quantity>1</Quantity>
</Item>
</OrderFulfillment>
</Message>
</AmazonEnvelope>
the code snippet is
import io
from sp_api.api import Feeds
credentials = {
'refresh_token': '***',
'lwa_app_id': '***',
'lwa_client_secret': '***',
'aws_access_key': '***',
'aws_secret_key': '***',
'role_arn': '***'
}
feeds_client = Feeds(credentials=credentials)
feed_content = '''<?xml version="1.0" encoding="UTF-8"?>
<AmazonEnvelope xsi:noNamespaceSchemaLocation="amzn-envelope.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>None</MerchantIdentifier>
</Header>
<MessageType>OrderFulfillment</MessageType>
<Message>
<MessageID>1</MessageID>
<OrderFulfillment>
<AmazonOrderID>order-id</AmazonOrderID>
<FulfillmentDate>2021-08-20T02:35:31.312036+00:00</FulfillmentDate>
<FulfillmentData>
<CarrierCode>carrier-code</CarrierCode>
<ShippingMethod>shipping method</ShippingMethod>
<ShipperTrackingNumber>tracking id</ShipperTrackingNumber>
</FulfillmentData>
<Item>
<AmazonOrderItemCode>order-item-id</AmazonOrderItemCode>
<Quantity>1</Quantity>
</Item>
</OrderFulfillment>
</Message>
</AmazonEnvelope>
'''
feed_file = io.StringIO(feed_content)
feed_type = 'POST_ORDER_FULFILLMENT_DATA'
response = feeds_client.create_feed_document(feed_file)
document_id = response.payload['feedDocumentId']
response = feeds_client.create_feed(feed_type, document_id)
feed_id = response.payload['feedId']
# You have to wait for few seconds for feed processing.
# Then when you get feed, it will show Feed Document ID
feed_response = feeds_client.get_feed(feed_id)
print(feed_response)
feed_result_document_id = feed_response['resultFeedDocumentId']
feed_result_response = feeds_client.get_feed_result_document(feed_result_document_id)
print(feed_result_response)
# If you see your message is success => you are done.
For this version, you gotta wait for few days/weeks for the author to update that, or you can go ahead to custom the class sp_api/api/feeds/feeds.py
so it can use the version 2021-06-31
. This is pretty simple.
Thanks a ton @chenlixin93
I have resolved my problem, just wanna share how it works in both versions.
I use the python package: https://github.com/saleweaver/python-amazon-sp-api/
Version 2020-09-04
I install the package python-amazon-sp-api, and use the old MWS feed message
<?xml version="1.0" encoding="UTF-8"?> <AmazonEnvelope xsi:noNamespaceSchemaLocation="amzn-envelope.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Header> <DocumentVersion>1.01</DocumentVersion> <MerchantIdentifier>None</MerchantIdentifier> </Header> <MessageType>OrderFulfillment</MessageType> <Message> <MessageID>1</MessageID> <OrderFulfillment> <AmazonOrderID>--------</AmazonOrderID> <FulfillmentDate>2021-08-20T02:35:31.312036+00:00</FulfillmentDate> <FulfillmentData> <CarrierCode>--------</CarrierCode> <ShippingMethod>--------</ShippingMethod> <ShipperTrackingNumber>--------</ShipperTrackingNumber> </FulfillmentData> <Item> <AmazonOrderItemCode>--------</AmazonOrderItemCode> <Quantity>1</Quantity> </Item> </OrderFulfillment> </Message> </AmazonEnvelope>
the code snippet is
import io from sp_api.api import Feeds credentials = { 'refresh_token': '***', 'lwa_app_id': '***', 'lwa_client_secret': '***', 'aws_access_key': '***', 'aws_secret_key': '***', 'role_arn': '***' } feeds_client = Feeds(credentials=credentials) feed_content = '''<?xml version="1.0" encoding="UTF-8"?> <AmazonEnvelope xsi:noNamespaceSchemaLocation="amzn-envelope.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Header> <DocumentVersion>1.01</DocumentVersion> <MerchantIdentifier>None</MerchantIdentifier> </Header> <MessageType>OrderFulfillment</MessageType> <Message> <MessageID>1</MessageID> <OrderFulfillment> <AmazonOrderID>order-id</AmazonOrderID> <FulfillmentDate>2021-08-20T02:35:31.312036+00:00</FulfillmentDate> <FulfillmentData> <CarrierCode>carrier-code</CarrierCode> <ShippingMethod>shipping method</ShippingMethod> <ShipperTrackingNumber>tracking id</ShipperTrackingNumber> </FulfillmentData> <Item> <AmazonOrderItemCode>order-item-id</AmazonOrderItemCode> <Quantity>1</Quantity> </Item> </OrderFulfillment> </Message> </AmazonEnvelope> ''' feed_file = io.StringIO(feed_content) feed_type = 'POST_ORDER_FULFILLMENT_DATA' response = feeds_client.create_feed_document(feed_file) document_id = response.payload['feedDocumentId'] response = feeds_client.create_feed(feed_type, document_id) feed_id = response.payload['feedId'] # You have to wait for few seconds for feed processing. # Then when you get feed, it will show Feed Document ID feed_response = feeds_client.get_feed(feed_id) print(feed_response) feed_result_document_id = feed_response['resultFeedDocumentId'] feed_result_response = feeds_client.get_feed_result_document(feed_result_document_id) print(feed_result_response) # If you see your message is success => you are done.
Version 2021-06-30
For this version, you gotta wait for few days/weeks for the author to update that, or you can go ahead to custom the class
sp_api/api/feeds/feeds.py
so it can use the version2021-06-31
. This is pretty simple
@joevu-stlpro
- about encrypt file( New version of Feeds API and Reports API released! #1107 ) :
We've been listening to your feedback and are removing the requirement for client-side encryption for Selling Partner API (SP-API) Feeds and Reports APIs.
- about only 2 keys : https://github.com/amzn/selling-partner-api-docs/blob/main/references/feeds-api/feeds_2021-06-30.md#createfeeddocumentresponse
- about POST_FLAT_FILE_INVLOADER_DATA : I have not used this template, you can just google
POST_FLAT_FILE_INVLOADER_DATA template
to find the answer. https://stackoverflow.com/questions/39289735/amazon-mws-api-submitfeed-post-flat-file-invloader-data-incorrect-template-typ As I konw, SP-API use the same xml format as MWS.
大佬,我这边标记发货有时成功有时失败,失败时大多的错误为
We are unable to process the XML feed because one or more items are invalid. Please re-submit the feed. --,可以帮一下我么
@yingyuhaonan 我的邮箱是 chenlixin93@gmail.com,可以的话在邮件里把问题描述下,最好是有相关代码和截图,也可以附上你的QQ方便联系。
@yingyuhaonan 我的邮箱是 chenlixin93@gmail.com,可以的话在邮件里把问题描述下,最好是有相关代码和截图,也可以附上你的QQ方便联系。
我的QQ 1242338047
@yingyuhaonan 可以看看我上面提到的 https://github.com/amzn/selling-partner-api-models/issues/1746 ,印象里api版本换到 21-06-30 就没什么问题了。
Hi There,
I have troubles with ill-formed
POST_ORDER_FULFILLMENT_DATA
feed. I do validate my xml content with the xsd file.The input xml data that I sent
The response I got from Amazon SP API