Skip to main content
Published: August 22 2006, 3:02:00 PMUpdated: November 28 2020, 2:28:06 PM

How can I log the API call request and response using the .NET SDK?


Detailed Description

Here is a C# sample code to log your call request and response using the .NET SDK:

    public ApiContext GetContext()
    {
        context = new ApiContext();
        //set the your credentials
        context.ApiCredential.eBayToken = "token";
        context.ApiCredential.ApiAccount.Application = "AppID";
        context.ApiCredential.ApiAccount.Developer = "DevID";
        context.ApiCredential.ApiAccount.Certificate = "CertID";
        context.SoapApiServerUrl = "url";

        //set the version
        context.Version = "465";

        //set the logging
        string logFile = "LogFile.txt";
        context.ApiLogManager = new ApiLogManager();
        context.ApiLogManager.ApiLoggerList.Add(new FileLogger(logFile, true, true, true));
        context.ApiLogManager.EnableLogging = true;

        return context;
    }

Although logging adds a little bit of an overhead to your application, it becomes fairly easy to track down errors.  


Version Info

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

API Schema Version 465
.NET SDK Version .NET SDK v465.0 full release

Note:  Although the above code sample is based on .NET SDK v465.0, it is applicable to all versions starting from 3.0.



Additional Resources

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