Search code examples
perlebay-api

Can't update description of listing with eBay API


I'm trying to write a Perl script that will update our eBay listings descriptions without having to keep logging in (running across multiple marketplaces if proving tricky to keep stock levels, descriptions etc updated). Here is what I have so far:

 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";

I get an error when running it though:

      '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.'
                  }
                ],

Am I misunderstanding what gets passed in? from what I can understand, you just pass in the params you want to change?

UPDATE: As suggested by Dave, I'm giving Marketplace::Ebay a go. Just testing by trying to select one of my items:

 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);

But I get some weird error:

error: element `{urn:ebay:apis:eBLBaseComponents}GiftIcon' not processed for {urn:ebay:apis:eBLBaseComponents}GetItemResponse/Item at //[5]/*[6] $VAR1 = undef;

Any ideas?


Solution

  • Ah ha - got it! The issue seemed to be around the way the HTML was being passed along. If I put it inside a CDATA tag, it works fine:

    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;
    

    ...and updates perfectly