【问题标题】:Etsy API python image uploadEtsy API python 图片上传
【发布时间】:2020-01-15 07:21:59
【问题描述】:

是否有人使用 python 通过 API 向 Etsy 添加列表? 我正在使用requests_oauthlib,但是想将图像上传到列表时不断出错。其他功能,如列表创建等。图片上传代码:

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

提前致谢!

【问题讨论】:

  • 这个问题解决了吗?
  • 不,从来都不是……
  • 您必须使用 files=files 上传,还有另一个关于它的 SO 问题
  • 能否给个链接?

标签: python image oauth multipart etsy


【解决方案1】:

我不能那样做。我不知道为什么。
但以下对我有用:

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 的新手

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-17
    • 2018-11-02
    • 1970-01-01
    • 1970-01-01
    • 2015-11-05
    • 2016-11-07
    • 1970-01-01
    相关资源
    最近更新 更多