Ebay API: 失败,需要 UUID
Ebay API: Failure, UUID required
我正在尝试使用 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
"user-token" 是在帐户设置、生产密钥下提供的长令牌。
但是我收到以下错误:
<?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>
从 C# 示例复制而来,UUID 是唯一的一次性使用值。在我使用的 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();
这是 eBay 开发者网络上列出的代码的逐字记录。
以下内容可能对移植到 Python 有用。
GUID Creation in Python -- Stack Overflow Thread
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
)
以上是对我有用的代码。创建一个 post 请求,而不是获取。
我正在尝试使用 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
"user-token" 是在帐户设置、生产密钥下提供的长令牌。
但是我收到以下错误:
<?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>
从 C# 示例复制而来,UUID 是唯一的一次性使用值。在我使用的 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();
这是 eBay 开发者网络上列出的代码的逐字记录。
以下内容可能对移植到 Python 有用。
GUID Creation in Python -- Stack Overflow Thread
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
)
以上是对我有用的代码。创建一个 post 请求,而不是获取。