etsy API 3 upload image in python

Skip to first unread message

Jan Masar

Sep 20, 2021, 8:51:25 AM9/20/21
to Etsy API
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.

I was tryng all this solutions:

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 =
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 =, headers=headers, data={'image': img})
try2 =, headers=headers, data={'image': read_image_file})
try3 =, headers=headers, data={'image': read_image_file_bytes})
try4 =, headers=headers, data={'image': read_image_file_bytes_str})

# trying to set existing image from my other listing
try_5 =, headers=headers, data={'listing_image_id': 2853097528})

but I always get the same response:
{'error': 'Either a valid image file or a listing_image_id must be provided.'}

Could you please let me know what I'm doing wrong?

Thank you

Adam Grant

Sep 22, 2021, 3:59:43 PM9/22/21
to Etsy API
I'm having the exact same problem when uploading images through the API, the URLs I'm using for my images are valid, but after it uploads 10 images or so it throws out errors saying URL invalid, after an hour or so it will let me do around another 10 images then does the same thing again.

Jan Masar

Sep 30, 2021, 2:56:08 PM9/30/21
to Etsy API

Could you please post here your PYTHON solution? Then at least I will know which one is working or which one should be working. Because none of mine (try1 to try5) is working. Im not able to add any image. 

Thank you.

Gareth Doherty

Oct 14, 2021, 8:29:24 AM10/14/21
to Etsy API

Julio Camejo Corona

Nov 18, 2021, 10:05:53 AM11/18/21
to Etsy API
Hello, I found the solution. The main key to the problem is sending "Content-Type" and that it's causing the error. My final code is:
files = {
"image": open(file_path, 'rb')
headers = {
"Authorization": "Bearer " + user_token,
"x-api-key": X_API_KEY
Reply all
Reply to author
0 new messages