Question

I am using eBay API to call GetSessionId method but the method returning me the empty SessionID in my ASP.NET MVC4 application.

Can anyone help me out whats the problem?

I am using the following code snippet.

 string signinURL = "https://api.sandbox.ebay.com/wsapi";
string callname = "GetSessionID";
string appID = ConfigurationManager.AppSettings["ebay_AppId"];
string version = "768";
string eBayToken = ConfigurationManager.AppSettings["testToken"];
string endpoint = signinURL + "?callname=" + callname +
                    "&appid=" + appID +
                    "&version=" + version +
                    "&routing=default";



eBayAPIInterfaceClient service = new eBayAPIInterfaceClient("eBayAPI", endpoint);
GetSessionIDRequest req = new GetSessionIDRequest();
req.RequesterCredentials = new CustomSecurityHeaderType();

req.RequesterCredentials.Credentials = new UserIdPasswordType();
req.RequesterCredentials.Credentials.AppId = AppConstants.AppId;
req.RequesterCredentials.Credentials.DevId = AppConstants.DevId;
req.RequesterCredentials.Credentials.AuthCert = AppConstants.CertId;
req.RequesterCredentials.eBayAuthToken = AppConstants.ebayToken;
GetSessionIDRequestType reqType = new GetSessionIDRequestType();
reqType.RuName = AppConstants.RuName;
reqType.Version = version;
GetSessionIDResponseType res = service.GetSessionID(ref req.RequesterCredentials, reqType);
if (res.Ack == AckCodeType.Success)
{
    string ebaySignInUrl = "https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&RuName=" + 
                           AppConstants.RuName + "&SessionID=" + res.SessionID;
    Response.Redirect(ebaySignInUrl);
}
Was it helpful?

Solution

Finally i figure out the problem, the problem is with the eBay API. It does not populate the SessionID field. May be the bug in the API. The retured value can be found in the XmlElement Array field of response object. So i get the SessionID as here.

if (response.Any.Length >= 1)
      {
        var SessionId=response.Any.First().InnerText;
      }
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top