[英]Ebay API: Failure, UUID required
I'm trying to get the active inventory for a client's Ebay store using the LMS Bulk Data Exchange API in Python. 我正在尝试使用Python中的LMS批量数据交换API获取客户的Ebay商店的活动库存。
import requests
token = "<user-token>"
headers = {"X-EBAY-SOA-OPERATION-NAME":"startDownloadJob", "X-EBAY-SOA-SECURITY-TOKEN":token}
r = requests.get('https://webservices.ebay.com/BulkDataExchangeService', headers = headers)
print r.text
The "user-token" is the long token provided under account settings, production keys. “用户令牌”是在帐户设置,生产密钥下提供的长令牌。
However I get the following error: 但是我收到以下错误:
<?xml version='1.0' encoding='UTF-8'?><startDownloadJobResponse xmlns="http://www.ebay.com/marketplace/services"><ack>Failure</ack><errorMessage><error><errorId>9</errorId><domain>Marketplace</domain><severity>Error</severity><category>Application</category><message>UUID is required</message><subdomain>BulkDataExchange</subdomain></error></errorMessage><version>1.5.0</version><timestamp>2016-01-28T08:52:52.987Z</timestamp></startDownloadJobResponse>
Copied from a C# example, the UUID is a unique one time use value. 从C#示例复制而来,UUID是唯一的一次性使用值。 In the C# bulk data exchange example I am using, it is populated as follows: 在我正在使用的C#批量数据交换示例中,其填充如下:
StartDownloadJobRequest req = new StartDownloadJobRequest();
req.downloadJobType = ReportType;
//Generate a UUID. UUID must be unique. Once used, you can't use it again
req.UUID = System.Guid.NewGuid().ToString();
That is verbatim from code listed on eBay Developers network. 这是eBay开发人员网络上列出的代码的逐字记录。
The following may be useful in porting over to Python. 以下内容可能对移植到Python有用。
GUID Creation in Python -- Stack Overflow Thread 用Python创建GUID-堆栈溢出线程
url = 'https://webservices.ebay.com/BulkDataExchangeService'
xml_request = '<?xml version="1.0" encoding="utf-8"?>\
<startDownloadJobRequest xmlns="http://www.ebay.com/marketplace/services">\
<downloadJobType>ActiveInventoryReport</downloadJobType>\
<UUID>%s</UUID>\
</startDownloadJobRequest>' % uid
print(xml_request)
request = requests.post(
url=url,
headers=headers,
data=xml_request
)
Above is code that worked for me. 以上是对我有用的代码。 Create a post request, rather than get. 创建一个发布请求,而不是获取。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.