Perl:连接到Walmart API以加载项目不支持的媒体类型错误

时间:2019-02-19 01:43:15

标签: perl walmart-api

我们正在尝试使用marketplace.walmartapis.com api批量列出商品,并且该商品返回的XML商品Feed不受支持的媒体类型

我们正在使用Perl,并且能够执行其他命令来更新库存和定价,检查订单,查找提要和skus等。令牌应该很好,因为我们使用相同的令牌进行了两次调用,而第一个调用呼叫(项目广告资源)在尝试发送xml文件之前按预期工作。只有当我们尝试发送xml批处理文件时,我们才遇到问题。

我们假设问题出在标头/身份验证上,并尝试了许多不同的组合。但是显然我们缺少了一些东西。

正在发送什么:

POST https://marketplace.walmartapis.com/v3/feeds?feedType=item HTTP/1.1

标题:

Authorization: Basic MDc4......
Content-Length: 2277
Accept: application/xml
Content-Type: multipart/formdata
Host: marketplace.walmartapis.com
WM_QOS.CORRELATION_ID: TB123456V32
WM_SEC.ACCESS_TOKEN: eyJra...
WM_SVC.NAME: Walmart Marketplace
Boundary: 1234ran4321dom5678boundary

formdata有效载荷:

--1234ran4321dom5678boundary
Content-Disposition: formdata; name="xml"
Content-length: 2151


<?xml version="1.0" encoding="UTF-8"?>
<MPItemFeed xmlns="http://walmart.com/">
  <MPItemFeedHeader>
    <version>3.1</version>
    <requestBatchId>......</requestBatchId>
    <feedDate>2019-02-18T19:45:17</feedDate>
    <mart>WALMART_US</mart>
  </MPItemFeedHeader>
  <MPItem>
    <processMode>CREATE</processMode>
    <sku>....</sku>
    <productIdentifiers>
      <productIdentifier>
        <productIdType>UPC</productIdType>
        <productId>..........</productId>
      </productIdentifier>
    </productIdentifiers>
    <MPProduct>
      <productName>.....................</productName>
      <category>
        <SportAndRecreation>
          <SportAndRecreationOther>
            <shortDescription>........................</shortDescription>
            <keyFeatures>
              <keyFeaturesValue>I...............</keyFeaturesValue>
            </keyFeatures>
            <brand>............</brand>
            <manufacturer>.............</manufacturer>
            <manufacturerPartNumber>.............</manufacturerPartNumber>
            <modelNumber>..</modelNumber>
            <mainImageUrl>............</mainImageUrl>
            <count>1</count>
            <isProp65WarningRequired>No</isProp65WarningRequired>
            <sportsLeague>
               <sportsLeagueValue>....</sportsLeagueValue>
            </sportsLeague>
            <keywords>................</keywords>
            <isMemorabilia>......</isMemorabilia>
            <isCollectible>...........</isCollectible>
          </SportAndRecreationOther>
        </SportAndRecreation>
      </category>
    </MPProduct>
    </MPOffer>
        <price>21.95</price>
        <StartDate>2019-02-23T19:45:17</StartDate>
        <EndDate>2019-04-19T19:45:17</EndDate>
        <ShippingWeight>
          <measure>2</measure>
          <unit>lb</unit>
        </ShippingWeight>
        <ProductTaxCode>2038345</ProductTaxCode>
    </MPOffer>
  </MPItem>
</MPItemFeed>
--1234ran4321dom5678boundary--

从Walmart.pm返回

$HASH = {
      "error" => {
                 "category" => "DATA",
                 "causes" => {},
                 "code" => "UNSUPPORTED_MEDIA_TYPE.GMP_GATEWAY_API",
                 "errorIdentifiers" => {},
                 "info" => "Unsupported Media Type.",
                 "severity" => "ERROR"
               },
      "xmlns:ns2" => "http://walmart.com/"
};

任何朝着正确方向的指针都会受到赞赏。

1 个答案:

答案 0 :(得分:1)

感谢所有看过的人。问题似乎已经解决

那是一个小错字

multipart / formdata必须是multipart / form-data

现在有了这一更改,我们得到了一个显示在“卖方”区域中的供稿ID