Skip to main content
Published: July 17 2007, 3:46:00 PMUpdated: August 03 2022, 1:54:48 PM

How can I set the DetailLevel or GranularityLevel for a call using the .NET SDK?

Summary

To set the DetailLevel for a call, you need to add the required DetailLevelCodeType to the call's DetailLevelList collection.  For GranularityLevel, you need to set the required GranularityLevelCodeType to the call's GranularityLevel property.
 


 

Detailed Description

Here are a couple of samples written in C# which demonstrate how to set the DetailLevel and GranularityLevel:
 
using System;
using eBay.Service.Call;
using eBay.Service.Core.Sdk;
using eBay.Service.Util;
using eBay.Service.Core.Soap;

namespace SDKExamples
{

public class Samples
{
     public ApiContext context;
 
public string GetItem(string ItemID)
{
  GetItemCall apicall = new GetItemCall(GetContext());
  //Set the DetailLevel to get the Attribute Information
  apicall.DetailLevelList.Add(DetailLevelCodeType.ItemReturnAttributes);
  apicall.ItemID = "110021195125";
  apicall.Execute();
  //Get the information from the response
  string  title = apicall.Item.Title;
}

public void GetSellerList()
{
    GetSellerListCall apicall = new GetSellerListCall(GetContext());
  TimeFilter tf = new TimeFilter();
  tf.TimeFrom =  DateTime.Now.AddMinutes(1);
  tf.TimeTo = DateTime.Now.AddDays(30);          
  apicall.EndTimeFilter = tf;
  //Set the GranularityLevel to Coarse
  apicall.GranularityLevel = GranularityLevelCodeType.Coarse;
  apicall.Pagination = new PaginationType();
  apicall.Pagination.EntriesPerPage = 200;
  apicall.Pagination.PageNumber = 1;
  apicall.Execute();

  //Process each item
  foreach( ItemType item in apicall.ItemList)
  {
      //do the processing
 
}
  //Get more pages if required, by incrementing apicall.Pagination.PageNumber
}
 

    public ApiContext GetContext()
    {

    if (context == null)
        {
           context = new ApiContext();

      // Set the Sandbox API Credentials for the call
      context.ApiCredential.eBayToken = "token";

      // Set the Sandbox 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 = "1131";

        }
   return context;
    }

}

}

 

 


Additional Resources

 

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

Got thoughts? Click the feedback button – your insights help us improve!