Python& Json - Ebay Api上传图片错误

时间:2017-02-05 17:28:18

标签: python json api

我一直在尝试使用return_file_upload调用将png图像上传到Ebay Api: http://developer.ebay.com/Devzone/post-order/post-order_v2_return-returnId_file_upload__post.html#Samples

它很奇怪,因为文档说它接受数据参数的数组,但样本不使用数组。当我尝试使用数组时,我得到了// main.js require('mymodule').then(MyModule => { MyModule.useDependency(); });

这是我的代码:

Can not deserialize instance of byte out of VALUE_STRING at [Source: java.io.SequenceInputStream@4d57f134; line: 1, column: 11] (through reference chain: com.ebay.marketplace.returns.v3.services.request.UploadFileRequest["data"])

目前的产出 import json import base64 import requests with open("take_full_login.png", "rb") as image_file: encoded_string = base64.encodestring(image_file.read()) url2 = 'https://api.ebay.com/post-order/v2/return/123456/file/upload' payload2 = { "data" : encoded_string, "filePurpose" : "LABEL_RELATED" } requests.post(url=url2, data=json.dumps(payload2), headers=headers)

1 个答案:

答案 0 :(得分:0)

尝试将data=json.dumps(payload2)替换为json=payload2

电话/后订单/ v2 /取消/ check_eligibility只对我有用