Open darecAdirondack opened 7 years ago
You have two options
Upload from file system https://github.com/timotheus/ebaysdk-python/blob/master/samples/trading.py#L227
Upload via External Source https://github.com/timotheus/ebaysdk-python/blob/master/samples/trading.py#L207
thanks, that helped me move onto the next few steps, but it seems im stuck again.
from PIL import Image
with Image.open(String_NewFileName) as im:
im.thumbnail((1600,1600))
with io.BytesIO() as fp:
im.save(fp, "JPEG")
files = {'file': ('EbayImage', fp.getvalue())}
pictureData = { "WarningLevel": "High",
"PictureSet":'Supersize', "PictureName": "WorldLeaders"}
response = api.execute('UploadSiteHostedPictures', pictureData, files=files)
print(response.reply.SiteHostedPictureDetails.FullURL)
Traceback (most recent call last):
File "<pyshell#23>", line 1, in <module>
ListItems("sandbox")
File "C:\My Python\AddItem_SingleUpload - Copy.py", line 108, in ListItems
response = api.execute('UploadSiteHostedPictures', pictureData, files=files)
File "C:\Users\OhioAuto\AppData\Local\Programs\Python\Python36\lib\site-packages\ebaysdk\connection.py", line 119, in execute
self.build_request(verb, data, verb_attrs, files)
File "C:\Users\OhioAuto\AppData\Local\Programs\Python\Python36\lib\site-packages\ebaysdk\connection.py", line 154, in build_request
data=smart_encode_request_data(requestData),
File "C:\Users\OhioAuto\AppData\Local\Programs\Python\Python36\lib\site-packages\ebaysdk\utils.py", line 95, in smart_encode_request_data
return value.encode('utf-8')
AttributeError: 'dict' object has no attribute 'encode'
It looks like what i had to do to fix my next problem of
AttributeError: 'dict' object has no attribute 'encode'
was to open up "AppData\Local\Programs\Python\Python36\lib\site-packages\ebaysdk\utils.py"
and change the line
return value.encode('utf-8')
to
return value
and it seemed to work for me fine after that.
big thanks!
Im not sure what format i should use to upload an image to my listings. The Trading API docs say that you should first call UploadSiteHostedPictures,this is how i sent my request.:
According to the Docs, im supposed to use PictureData which is described as:
PictureData ( Base64BinaryType (base64Binary) ) [0..1] An optional reference ID to the binary attachment. The PictureData field does not contain the binary attachment. The binary attachment is image data, including the headers, from a JPG, GIF, PNG, BMP, or TIF format image file. The binary attachment must be sent as a MIME attachment, in your POST request, after the XML input.
but im not sure what a MIME request even is, or how i would prepare it for sending. could anyone offer some assistance here? i thought maybe just inserting the path would work like so, but received an exception.
Traceback (most recent call last): File "<pyshell#4>", line 1, in
api.execute('UploadSiteHostedPictures',{'PictureData': 'C:/My Python/cool.jpg'})
File "C:\Users\OhioAuto\AppData\Local\Programs\Python\Python36\lib\site-packages\ebaysdk\connection.py", line 124, in execute
self.error_check()
File "C:\Users\OhioAuto\AppData\Local\Programs\Python\Python36\lib\site-packages\ebaysdk\connection.py", line 213, in error_check
raise ConnectionError(estr, self.response)
ebaysdk.exception.ConnectionError: 'UploadSiteHostedPictures: Class: RequestError, Severity: Error, Code: 20170, Schema XML request error. Schema XML request error: Bad character or insufficient number of characters in hex string.'