This question isn't specific to Python at all, given that I know all the same HTTP API calls are made regardless of what SDK is being used.
I have a bunch of listings (hundreds) that I need to change programmatically. The need is just to change the Variation pictures of an item. Using the ReviseItem API has not been working as expected for me.
Details:
If I do a GetItem request for itemID 332121070278, I get the following response back:
<?xml version="1.0" encoding="UTF-8"?>
<GetItemResponse xmlns="urn:ebay:apis:eBLBaseComponents">
<Timestamp>2018-02-05T16:46:02.399Z</Timestamp>
<Ack>Success</Ack>
<Version>1035</Version>
<Build>E1035_INTL_API_18562923_R1</Build>
<Item>
<ItemID>332121070278</ItemID>
<Variations>
<Pictures>
<VariationSpecificName>Colour</VariationSpecificName>
<VariationSpecificPictureSet>
<VariationSpecificValue>Navy</VariationSpecificValue>
<PictureURL>https://s3-eu-west-1.amazonaws.com/images.linnlive.com/b3bb06dbe22847df07835760a144c5dd/3e11c104-311f-4faa-b308-e6d40f6a3c6a.jpg</PictureURL>
<ExternalPictureURL>https://s3-eu-west-1.amazonaws.com/images.linnlive.com/b3bb06dbe22847df07835760a144c5dd/3e11c104-311f-4faa-b308-e6d40f6a3c6a.jpg</ExternalPictureURL>
</VariationSpecificPictureSet>
<VariationSpecificPictureSet>
<VariationSpecificValue>Olive</VariationSpecificValue>
<PictureURL>https://s3-eu-west-1.amazonaws.com/images.linnlive.com/b3bb06dbe22847df07835760a144c5dd/881a11fe-bb73-4d3a-a556-cdecae2ee723.jpg</PictureURL>
<ExternalPictureURL>https://s3-eu-west-1.amazonaws.com/images.linnlive.com/b3bb06dbe22847df07835760a144c5dd/881a11fe-bb73-4d3a-a556-cdecae2ee723.jpg</ExternalPictureURL>
</VariationSpecificPictureSet>
<VariationSpecificPictureSet>
<VariationSpecificValue>Nearly Black</VariationSpecificValue>
<PictureURL>https://s3-eu-west-1.amazonaws.com/images.linnlive.com/b3bb06dbe22847df07835760a144c5dd/211f43f9-a4fd-40fd-9712-743e5ab328d0.jpg</PictureURL>
<ExternalPictureURL>https://s3-eu-west-1.amazonaws.com/images.linnlive.com/b3bb06dbe22847df07835760a144c5dd/211f43f9-a4fd-40fd-9712-743e5ab328d0.jpg</ExternalPictureURL>
</VariationSpecificPictureSet>
<VariationSpecificPictureSet>
<VariationSpecificValue>Wine</VariationSpecificValue>
<PictureURL>https://s3-eu-west-1.amazonaws.com/images.linnlive.com/b3bb06dbe22847df07835760a144c5dd/27f7768e-3987-4ff4-9440-614c0853b0cb.jpg</PictureURL>
<ExternalPictureURL>https://s3-eu-west-1.amazonaws.com/images.linnlive.com/b3bb06dbe22847df07835760a144c5dd/27f7768e-3987-4ff4-9440-614c0853b0cb.jpg</ExternalPictureURL>
</VariationSpecificPictureSet>
</Pictures>
</Variations>
</Item>
</GetItemResponse>
So in order to submit my ReviseItem request in the Python SDK, I did the following:
def reviseItem(opts):
try:
api = Trading(debug=opts.debug, config_file=opts.yaml, appid=opts.appid,
certid=opts.certid, devid=opts.devid, warnings=True, timeout=20, siteid='3')
response = api.execute('ReviseItem', {'Item': {
'ItemID': '332121070278',
'Variations': {
'Pictures': {
'VariationSpecificPictureSet': [
{
'PictureURL': 'https://cdn.shopify.com/s/files/1/0740/6535/products/wine_1_43df4936-4a20-4419-8643-40575a9bb457.jpg?v=1479773519',
'ExternalPictureURL': 'https://cdn.shopify.com/s/files/1/0740/6535/products/wine_1_43df4936-4a20-4419-8643-40575a9bb457.jpg?v=1479773519',
'VariationSpecificValue': 'Wine'
}
]
}
}
}})
#dump(api, full=False)
return response
except ConnectionError as e:
print(e)
print(e.response.dict())
... Which, when I check the request that actually went out, produced the expected XML:
<?xml version='1.0' encoding='utf-8'?>
<ReviseItemRequest xmlns="urn:ebay:apis:eBLBaseComponents">
<RequesterCredentials>
<eBayAuthToken>...</eBayAuthToken>
</RequesterCredentials>
<Item>
<ItemID>332121070278</ItemID>
<Variations>
<Pictures>
<VariationSpecificPictureSet>
<ExternalPictureURL>https://cdn.shopify.com/s/files/1/0740/6535/products/wine_1_43df4936-4a20-4419-8643-40575a9bb457.jpg?v=1479773519</ExternalPictureURL>
<PictureURL>https://cdn.shopify.com/s/files/1/0740/6535/products/wine_1_43df4936-4a20-4419-8643-40575a9bb457.jpg?v=1479773519</PictureURL>
<VariationSpecificValue>Wine</VariationSpecificValue>
</VariationSpecificPictureSet>
</Pictures>
</Variations>
</Item>
</ReviseItemRequest>
Seems totally correct to me. And I can make other ReviseItem API calls that work (e.g. I can successfully change the title of a listing using ReviseItem), but changing the Variation images is giving me the error "ReviseItem: Class: RequestError, Severity: Error, Code: 10007, Internal error to the application. Internal error to the application."
every time
Turns out the API doesn't accept VariationSpecificPictureSet without VariationSpecificName. My api call above works perfectly with a small amendment:
response = api.execute('ReviseItem', {'Item': {
'ItemID': '332121070278',
'Variations': {
'Pictures': {
'VariationSpecificName': 'Colour',
'VariationSpecificPictureSet': [
{
'PictureURL': 'https://cdn.shopify.com/s/files/1/0740/6535/products/wine_1_43df4936-4a20-4419-8643-40575a9bb457.jpg?v=1479773519',
'ExternalPictureURL': 'https://cdn.shopify.com/s/files/1/0740/6535/products/wine_1_43df4936-4a20-4419-8643-40575a9bb457.jpg?v=1479773519',
'VariationSpecificValue': 'Wine'
}
]
}
}
}})