etsyapi python图像上传
有人使用python使用API向Etsy添加列表吗? 我使用的是requests_oauthlib,但当我想将图像上传到列表时,会不断出错。其他功能,如列表创建等正在运行。图像上传代码:etsyapi python图像上传,python,image,oauth,multipart,etsy,Python,Image,Oauth,Multipart,Etsy,有人使用python使用API向Etsy添加列表吗? 我使用的是requests_oauthlib,但当我想将图像上传到列表时,会不断出错。其他功能,如列表创建等正在运行。图像上传代码: self.oauth = OAuth1(self.api_key, client_secret=self.api_secret, resource_owner_key=self.oauth_token,
self.oauth = OAuth1(self.api_key,
client_secret=self.api_secret,
resource_owner_key=self.oauth_token,
resource_owner_secret=self.oauth_token_secret)
def upload_picture(self):
url = "https://openapi.etsy.com/v2/listings/{listing_id}/images"
headers = {
"Content-Type": "multipart/form-data",
}
request = {
'image': ('img8.jpg', open('./img8.jpg', 'rb'), 'image/jpeg'),
}
r = requests.post(url=url, params=request, auth=self.oauth, headers=headers)
print(r.content)
错误:
oauth_problem=signature_invalid
提前谢谢 我不能那样做。我不知道为什么。 但下面的内容对我很有用:
etsy = OAuth1Session(
ApplicationKey,
ApplicationSecret,
token, token_secret
)
url = "https://openapi.etsy.com/v2/listings/{listing_id}/images"
request = { 'image': open('./img8.jpg', 'rb') }
response = etsy.post(url, files = request)
我对OAuth和Etsy API都是新手,这个问题解决了吗?不,从来没有解决过…你必须用files=files上传还有一个问题,你能链接一下吗?