python-shopee icon indicating copy to clipboard operation
python-shopee copied to clipboard

Can't upload image in version 2.0

Open gr3yw0rm opened this issue 3 years ago • 6 comments

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&timestamp=%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&timestamp=%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 avatar Jul 13 '21 13:07 gr3yw0rm

@gr3yw0rm have you solved it?

tjengbudi avatar Oct 25 '21 04:10 tjengbudi

I'm getting the same error as you, is there any other solution? I'm testing in php, not python.

plk3314 avatar Nov 15 '21 02:11 plk3314

I'm getting the same error as you, is there any other solution? I'm testing in php, not python.

have you solved it?

IDEALdream avatar Dec 03 '21 07:12 IDEALdream

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&timestamp=%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&timestamp=%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?

IDEALdream avatar Dec 03 '21 07:12 IDEALdream

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"}

raoulalwani avatar Aug 11 '22 10:08 raoulalwani

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

Delvinlim avatar May 05 '24 16:05 Delvinlim