Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't upload image in version 2.0 #43

Open
gr3yw0rm opened this issue Jul 13, 2021 · 6 comments
Open

Can't upload image in version 2.0 #43

gr3yw0rm opened this issue Jul 13, 2021 · 6 comments

Comments

@gr3yw0rm
Copy link

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

@tjengbudi
Copy link
Contributor

@gr3yw0rm have you solved it?

@plk3314
Copy link

plk3314 commented Nov 15, 2021

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

@IDEALdream
Copy link

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
Copy link

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?

@raoulalwani
Copy link

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

@Delvinlim
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants