Uploading Product Images VIA API and Primary Image Wanted Not Showing as Primary #1228
-
As the title of this post states, I'm using the API to upload 7 images for a listing and that works perfect, but I want the image that is watermarked to be the primary image and it isn't. The watermarked image is actually showing as the last image in the listing. I tried two different things:
Any help with this would be much appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
i figured it out. It needed a "rank". i didn't even know that existed until now. here is a simplified version made in Python if anyone else runs into the same problem. `import requests API_KEY = 'your_api_key' primary_image_path = 'path/to/your/primary_image.png' # This will be set as the primary image (rank 1) def upload_image(listing_id, file_path, rank): if name == 'main': |
Beta Was this translation helpful? Give feedback.
i figured it out. It needed a "rank". i didn't even know that existed until now.
here is a simplified version made in Python if anyone else runs into the same problem.
`import requests
from requests_toolbelt.multipart.encoder import MultipartEncoder
API_KEY = 'your_api_key'
OAUTH_TOKEN = 'your_oauth_token'
SHOP_ID = 'your_shop_id'
LISTING_ID = 'your_listing_id'
primary_image_path = 'path/to/your/primary_image.png' # This will be set as the primary image (rank 1)
second_image_path = 'path/to/your/second_image.png'
third_image_path = 'path/to/your/third_image.png'
def upload_image(listing_id, file_path, rank):
"""Uploads an image to the specified listing with a specified rank."""
url = f'ht…