I'm working with etsy API 3 on my website and I'm stuck on how to upload image to my draft listing in python.
headers = {
"Content-Type": "multipart/form-data",
"x-api-key": settings.ETSY_API_KEY,
"Authorization": f"Bearer {access_token}" # listings_w set in scope
}
image_file = open('static/images/CACHE/images/product/000063_1-dsc05556/test_file.jpg', 'rb')
read_image_file = image_file.read()
read_image_file_bytes = base64.b64encode(read_image_file)
read_image_file_bytes_str = "".join([format(n, 'b') for n in read_image_file_bytes])
try1 =
requests.post(url=url, headers=headers, data={'image': img})
try2 =
requests.post(url=url, headers=headers, data={'image': read_image_file})
try3 =
requests.post(url=url, headers=headers, data={'image': read_image_file_bytes})
try4 =
requests.post(url=url, headers=headers, data={'image': read_image_file_bytes_str})
# trying to set existing image from my other listing
try_5 =
requests.post(url=url, headers=headers, data={'listing_image_id': 2853097528})