简体   繁体   English

发布项目沃尔玛合作伙伴 API Python

[英]Post Item Walmart Partner API Python

I am using walmart partner api with python script.我正在将walmart 合作伙伴 api与 python 脚本一起使用。 What I am trying to do is uploading item file using httplib.我想要做的是使用 httplib 上传项目文件。 Here is my code:这是我的代码:

file = open('/opt/item.xml', 'rb')
headers = {
        "Accept":ws_accept,
        "WM_SVC.NAME": wm_svc_name,
        "WM_CONSUMER.ID":wm_consumer_id,
        "WM_SEC.TIMESTAMP": wm_sec_timestamp,
        "WM_SEC.AUTH_SIGNATURE":wm_sec_auth_signature,
        "WM_QOS.CORRELATION_ID": wm_qos_correlation_id,
        "Content-Type": 'multipart/form-data; boundary=xxx',
        "Host":'marketplace.walmartapis.com'
      }

conn = httplib.HTTPSConnection('marketplace.walmartapis.com')
conn.request("POST", '/v2/feeds?feedType=item',file, headers)

response = conn.getresponse()
print response.status, response.reason
print 'response',response.read()

item.xml is sample file available in documention. item.xml 是文档中提供的示例文件。

Response is here:回复在这里:

500 Internal Server Error
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <ns2:errors xmlns:ns2="http://walmart.com/">
   <ns2:error>
     <ns2:code>SYSTEM_ERROR.GMP_GATEWAY_API</ns2:code>
     <ns2:description>Couldn't find MIME boundary: --xxx</ns2:description>
     <ns2:info>System encountered some internal error.</ns2:info>    
     <ns2:severity>ERROR</ns2:severity>
     <ns2:category>DATA</ns2:category>
     <ns2:causes/>
     <ns2:errorIdentifiers/>
    </ns2:error>
</ns2:errors>

Hope someone familiar with walmart partner api.希望有人熟悉沃尔玛合作伙伴api。 Otherwise suggest with multipart-boundary error and how can I fix this please help guys...否则建议多部分边界错误,我该如何解决这个问题,请帮助大家...

From my personal experience, you may want to actually ask Walmart, "Have you received my file?"根据我的个人经验,你可能真的想问沃尔玛,“你收到我的文件了吗?” I have gotten 500s and 400s from them before with their other APIs and it has gone through the first run even though the API response code was not 200.我之前用他们的其他 API 从他们那里得到了 500 和 400,即使 API 响应代码不是 200,它也已经通过了第一次运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM