首页 > 解决方案 > 无法使用 eBay API 更新列表的描述

问题描述

我正在尝试编写一个Perl脚本,该脚本将更新我们的eBay 列表描述,而无需继续登录(如果证明很难保持库存水平、描述等更新,则跨多个市场运行)。这是我到目前为止所拥有的:

 my $ebay = new Net::eBay( {
                              SiteLevel => 'prod',
                              DeveloperKey => 'x',
                              ApplicationKey => 'x',
                              CertificateKey => 'x',
                              Token => 'x',
                             } );

  $ebay->setDefaults( { API => 2, compatibility => 900  } );

my $new_desc = q|<meta name="viewport" content="width=device-width, initial-scale=1.0">
<p>We are proud to announce our first ever badge! With an easy-to-iron
on backing, fitting couldn't be any easier! We have designed the path to
 be a perfect addition to any piece of cosplay costume.&nbsp; Please do send
in the photos of it being used on your costumes, as we would love to
share.</p>
<p>The badge is 7 x 7 cm / 2 x 2 inches in size, and 2mm thi<br></p>|;

my $result = $ebay->submitRequest( "ReviseItem",
                      {
                       DetailLevel => "ReturnAll",
                       ErrorLevel => "1",
                       SiteId => "1",
                       Item => {
                         Description => \$new_desc,
                         ItemID => 253430606975
                       },
                       ItemID => 253430606975
                      }) || die;

 print "Result: " . Dumper( $result ) . "\n";

运行它时出现错误:

      'Errors' => [
                  {
                    'ShortMessage' => 'Return Policy Attribute Not Valid',
                    'ErrorClassification' => 'RequestError',
                    'ErrorCode' => '21920200',
                    'LongMessage' => 'Return Policy Attribute returnDescription Not Valid On This Site',
                    'SeverityCode' => 'Warning',
                    'ErrorParameters' => {
                                         'Value' => 'returnDescription',
                                         'ParamID' => '0'
                                       }
                  },
                  {
                    'ShortMessage' => 'Description is missing.',
                    'ErrorClassification' => 'RequestError',
                    'ErrorCode' => '106',
                    'SeverityCode' => 'Error',
                    'LongMessage' => 'A description is required.'
                  }
                ],

我是否误解了传入的内容?据我了解,您只需传入要更改的参数?

更新:正如 Dave 所建议的,我正在给Marketplace::Ebay 试一试。只是通过尝试选择我的一项来进行测试:

 my $ebay = Marketplace::Ebay->new(
                                  production => 1,
                                  site_id => 3,
                                  developer_key => 'xx',
                                  application_key => 'xx',
                                  certificate_key => 'xxx',
                                  token => 'xx',
                                  xsd_file => 'ebaySvc.xsd',
                                 );

my $res = $ebay->api_call('GetItem', { ItemID => 253430606975 });
print Dumper($res);

但我得到一些奇怪的错误:

错误:元素 `{urn:ebay:apis:eBLBaseComponents}GiftIcon' 未处理 {urn:ebay:apis:eBLBaseComponents}GetItemResponse/Item at // [ 5]/*[6] $VAR1 = undef;

有任何想法吗?

标签: perlebay-api

解决方案


啊哈——明白了!问题似乎与传递 HTML 的方式有关。如果我把它放在一个CDATA标签里,它工作正常:

my $new_desc = q|<![CDATA[
some html etc here
]]>|;

my $result = $ebay->submitRequest( "ReviseItem",
                      {
                       DetailLevel => "ReturnAll",
                       ErrorLevel => "1",
                       SiteId => "1",
                       Item => {
                         Description => $new_desc,
                         ItemID => 253430606975
                       },
                       ItemID => 253430606975
                      }) || die;

...并完美更新


推荐阅读