Skip to main content
Published: November 26 2013, 4:06:00 PMUpdated: November 28 2020, 3:15:42 PM

Sample code in C# to remove BuyItNowPrice and Pictures from an Item using .NET SDK


Summary

Depending on what you want to delete, you either need to send in the information again in your call or send it in the DeletedField list.


Detailed Description

Here is a sample C# code using .NET SDK to demonstrate the use of DeletedFieldList:
 

  /*
© 2007-2013 eBay Inc., All Rights Reserved
Licensed under CDDL 1.0 - http://opensource.org/licenses/cddl1.php
*/ 

 

using System;
using eBay.Service.Call;
using eBay.Service.Core.Sdk;
using eBay.Service.Util;
using eBay.Service.Core.Soap;

namespace SDK3Examples
{

public class RelistItem
{
public string RelistItem(string itemID, string UUID)
{
   RelistItemCall apicall = new RelistItemCall(GetContext());
    ItemType item = new ItemType();   
   
item.ItemID = ItemID;
    apicall.DeletedFieldList = new StringCollection();
    // Remove the BuyItNowPrice
    apicall.DeletedFieldList.Add('Item.BuyItNowPrice');

    //Remove All the pictures
    apicall.DeletedFieldList.Add('Item.PictureDetails.PictureURL');
    item.PictureDetails = new PictureDetailsType();
    // Set the GalleryURL and PhotoDisplay to None
    item.PictureDetails.GalleryType = GalleryTypeCodeType.None;
    item.PictureDetails.PhotoDisplay = PhotoDisplayCodeType.None;
    //Remove All the pictures

    //To modify the Pictures
    //item.PictureDetails = new PictureDetailsType();
    //item.PictureDetails.PictureURL = new StringCollection();
    //item.PictureDetails.PictureURL.Add('http://www.mydomain.com/picture1.jpg');
    //item.PictureDetails.GalleryType = GalleryTypeCodeType.None;
    //item.PictureDetails.PhotoDisplay = PhotoDisplayCodeType.None;
    //To modify the Pictures

    item.UUID = UUID;
    apicall.RelistItem(item);
   
    FeeTypeCollection fees = addItem.AddItem(item);
    return  apicall.ItemID;
}

    public ApiContext GetContext()
    {
       ApiContext context = new ApiContext();

  // Credentials for the call
  context.ApiCredential.ApiAccount.Developer = 'devID';
  context.ApiCredential.ApiAccount.Application = 'appID';
  context.ApiCredential.ApiAccount.Certificate = 'certID';
  context.ApiCredential.eBayToken = 'token';

  // Set the URL
  context.SoapApiServerUrl = 'https://api.sandbox.ebay.com/wsapi'; 

  // Set logging
  context.ApiLogManager = newApiLogManager();
  context.ApiLogManager.ApiLoggerList.Add(new eBay.Service.Util.FileLogger('Messages.log', true, true, true));
  context.ApiLogManager.EnableLogging = true;

  // Set the version
  context.Version = '485';

  return context;

    }

}

}

To replace the pictures with new pictures, comment the Block 'Remove All the pictures' and uncomment the block 'To modify the Pictures'.   If you need to set the GalleryURL or specify multiple pictures, set the GalleryType and PhotoDisplay accordingly.

Here is the SOAP Request to  Remove BuyItNowPrice and All Pictures:

<?xml version='1.0' encoding='utf-8'?>

<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>

  <soap:Header>

    <RequesterCredentials xmlns='urn:ebay:apis:eBLBaseComponents'>

      <eBayAuthToken>******</eBayAuthToken>

      <Credentials>

        <AppId/>

        <DevId/>

        <AuthCert/>

      </Credentials>

    </RequesterCredentials>

  </soap:Header>

  <soap:Body>

    <RelistItemRequest xmlns='urn:ebay:apis:eBLBaseComponents'>

      <MessageID>ef57b868-5335-4600-b611-cbe416d81551</MessageID>

      <Version>485</Version>

      <Item>

        <ItemID>110015328466</ItemID>

        <PictureDetails>

          <GalleryType>None</GalleryType>

          <PhotoDisplay>None</PhotoDisplay>

        </PictureDetails>

      </Item>

      <DeletedField>Item.BuyItNowPrice</DeletedField>

      <DeletedField>Item.PictureDetails.PictureURL</DeletedField>

    </RelistItemRequest>

  </soap:Body>

</soap:Envelope>

Here is the SOAP request to replace the existing pictures:
 

<?xml version='1.0' encoding='utf-8'?>

<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>

  <soap:Header>

    <RequesterCredentials xmlns='urn:ebay:apis:eBLBaseComponents'>

      <eBayAuthToken>******</eBayAuthToken>

      <Credentials>

        <AppId/>

        <DevId/>

        <AuthCert/>

      </Credentials>

    </RequesterCredentials>

  </soap:Header>

  <soap:Body>

    <RelistItemRequest xmlns='urn:ebay:apis:eBLBaseComponents'>

      <MessageID>2ca341b6-f706-4b3f-9a75-186f622d7b53</MessageID>

      <Version>485</Version>

      <Item>

        <ItemID>110015328466</ItemID>

        <PictureDetails>

          <GalleryType>None</GalleryType>

          <PhotoDisplay>None</PhotoDisplay>

          <PictureURL>http://www.mydomain.com/picture1.jpg</PictureURL>

        </PictureDetails>

      </Item>

      <DeletedField>Item.BuyItNowPrice</DeletedField>

    </RelistItemRequest>

  </soap:Body>

</soap:Envelope>
 


Version Info

The code example above was based on the versions specified below:

API Schema Version 485
.NET SDK Version .NET SDK v485.0 full release



Additional Resources

How well did this answer your question?
Answers others found helpful