上传 eBay 运输标签时出现 400 错误

问题描述 投票:0回答:0

无法将退货标签上传到 ebay。我发送了以下内容,但它给我一个 400 错误响应。我的猜测是我构建“数据”的方式有问题,但我无法弄清楚是什么。我认为这些标头是正确的,因为它们是我毫无问题地为所有其他 API 调用传递的标头。

退货标签的工作方式是您首先通过以下端点将文件上传到 ebay:

https://api.ebay.com/post-order/v2/return/{returnId}/file/upload

然后您通过第二次调用跟进,使买家可以通过 POST /post-order/v2/return/{returnId}/add_shipping_label 访问标签

我需要的所有变量(returnId、endpoint_full)都在前面定义,base64_return_label_pdf(我计划发送的运输退货标签的 base 64 编码)也是如此。它们是字符串。

这是给我抛出 400 错误的代码:

response = requests.post(endpoint_full,
    headers={
        "Content-Type": "application/json",
        "Accept": "application/json",
        "Authorization": "IAF " + auth_token,
        "X-EBAY-C-MARKETPLACE-ID": "EBAY_US"
    },
    data={
        "UploadFileRequest": {
            "data": base64_return_label_pdf,
            "filePurpose": "LABEL_RELATED"
        }
    }
)

有什么想法吗?以下文档的一些链接:

https://developer.ebay.com/devzone/post-order/post-order_v2_return-returnid_file_upload__post.html

https://developer.ebay.com/devzone/post-order/types/UploadFileRequest.html

我尝试过各种方式重组数据,但都无济于事。文档还说某些文件可能需要编码两次,但没有详细说明。

python python-requests ebay-api http-status-code-400 ebay-sdk
© www.soinside.com 2019 - 2024. All rights reserved.