python-shopee
python-shopee copied to clipboard
Can't upload image in version 2.0
Has anyone successfully uploaded an image in the media space? Shopee's API doc is currently vague and incomplete. I've tried posting with the image's URL and binary code (see sample code below). Even the api test tool is showing the same error message.
Code 1:
headers = {'Content-Type': 'application/json'}
url = "https://partner.test-stable.shopeemobile.com/api/v2/media_space/upload_image?partner_id=%s&shop_id=%s×tamp=%s&access_token=%s"
body = {'image': 'https://cdn.shopify.com/s/files/1/0361/1738/1164/products/bcb5f0e09d312e2d849b3299ea2af01a.jpg?v=1619836687'}
response = requests.post(url, json=body, headers=headers)
Code 2:
headers = {'Content-Type': 'image/jpeg'}
url = "https://partner.test-stable.shopeemobile.com/api/v2/media_space/upload_image?partner_id=%s&shop_id=%s×tamp=%s&access_token=%s"
body = {'media': open('test.jpg', 'rb')}
response = requests.post(url, files=body, headers=headers)
print(response)
{'error': 'prodct.error_param', 'message': "can't find image file", 'warning': '', 'request_id': '354d1e0b625c3db6f2c12e25196dcb1c'}
@gr3yw0rm have you solved it?
I'm getting the same error as you, is there any other solution? I'm testing in php, not python.
I'm getting the same error as you, is there any other solution? I'm testing in php, not python.
have you solved it?
Has anyone successfully uploaded an image in the media space? Shopee's API doc is currently vague and incomplete. I've tried posting with the image's URL and binary code (see sample code below). Even the api test tool is showing the same error message.
Code 1:
headers = {'Content-Type': 'application/json'} url = "https://partner.test-stable.shopeemobile.com/api/v2/media_space/upload_image?partner_id=%s&shop_id=%s×tamp=%s&access_token=%s" body = {'image': 'https://cdn.shopify.com/s/files/1/0361/1738/1164/products/bcb5f0e09d312e2d849b3299ea2af01a.jpg?v=1619836687'} response = requests.post(url, json=body, headers=headers)
Code 2:
headers = {'Content-Type': 'image/jpeg'} url = "https://partner.test-stable.shopeemobile.com/api/v2/media_space/upload_image?partner_id=%s&shop_id=%s×tamp=%s&access_token=%s" body = {'media': open('test.jpg', 'rb')} response = requests.post(url, files=body, headers=headers)
print(response)
{'error': 'prodct.error_param', 'message': "can't find image file", 'warning': '', 'request_id': '354d1e0b625c3db6f2c12e25196dcb1c'}
have you solved it?
Has anyone managed to get this to work? Are they expecting an image URL or a blob? Getting an error as follows:
{"error"=>"product.error_param", "message"=>"form not found in request : form not found in request"}
i manage to fix this, it was on the library itself where we push fix application/json content-type headers you guys can modify the code to use multipart/form-data and apply some modification on image processing using Pillow library