2017-12-08 10 views
0

私はeBayの私の店からすべての商品を取りたいと思っています。これは私のコード が必要です。私はeBayの開発者 プログラムに自分自身を登録した後、私は生産用の鍵を作成しました。私のコードは、このコードを実行した後、私は、「APIリクエストで認証トークンの検証 に失敗しました。」このAPIの例外を取得していますAPI要求の認証トークンの検証に失敗しました。 eBayの使用.Net SDK

#region Feilds 
ApiContext ApiContext = new ApiContext(); 
CallRetry OCallRetry = new CallRetry(); 
ApiCall ApiCall = new ApiCall(); 
GetItemCall GetCall = new GetItemCall(); 

#endregion 

#region Utilities 
public void GetCredentials() 
{ 
    ApiContext.ApiCredential.ApiAccount.Developer = "xxxxxxxx";   //use your dev ID 
    ApiContext.ApiCredential.ApiAccount.Application = "xxxxxx";  //use your app ID 
    ApiContext.ApiCredential.ApiAccount.Certificate = "xxxxxxxxxxxx";   //use your cert ID 
    ApiContext.ApiCredential.eBayToken = ConfigurationManager.AppSettings["Token"];     //set the AuthToken 
} 

public void InitializeAPI() 
{ 
    ApiContext.SoapApiServerUrl = "https://api.ebay.com/wsapi"; 
    ApiContext.Site = eBay.Service.Core.Soap.SiteCodeType.India; 
    ApiContext.Version = "459"; 
} 

public void SetupAPILog() 
{ 
    //very important, let's setup the logging 
    ApiLogManager ApiLog = new ApiLogManager(); 
    ApiLog.ApiLoggerList.Add(new eBay.Service.Util.FileLogger("GetSellerList459NETSDK.log", true, true, true)); 
    ApiLog.EnableLogging = true; 
    ApiContext.ApiLogManager = ApiLog; 
} 

public void ConsumeAPI() 
{ 

    OCallRetry.DelayTime = 1; 
    OCallRetry.MaximumRetries = 3; 
    StringCollection oErrorCodes = new StringCollection(); 
    oErrorCodes.Add("10007"); 
    oErrorCodes.Add("2"); 
    oErrorCodes.Add("251"); 
    OCallRetry.TriggerErrorCodes = oErrorCodes; 
    TypeCollection oExceptions = new TypeCollection(); 
    oExceptions.Add(typeof(System.Net.ProtocolViolationException)); 

    oExceptions.Add(typeof(SdkException)); 
    OCallRetry.TriggerExceptions = oExceptions; 
    ApiContext.CallRetry = OCallRetry; 
    ApiContext.Timeout = 120000; 
    GetSellerListCall ApiSellerList = new GetSellerListCall(ApiContext); 

    ApiSellerList.Version = ApiContext.Version; 
    ApiSellerList.Site = ApiContext.Site; 
    ApiSellerList.GranularityLevel = eBay.Service.Core.Soap.GranularityLevelCodeType.Fine; 

    // enable the compression feature 
    ApiSellerList.EnableCompression = true; 
    ApiSellerList.DetailLevelList.Add(eBay.Service.Core.Soap.DetailLevelCodeType.ReturnAll); 

    PaginationType oPagination = new PaginationType(); 
    oPagination.EntriesPerPage = 200; 
    oPagination.EntriesPerPageSpecified = true; 
    oPagination.PageNumber = 1; 
    oPagination.PageNumberSpecified = true; 
    ApiSellerList.Pagination = oPagination; 
    ApiSellerList.EndTimeFilter = new TimeFilter(DateTime.Now, DateTime.Now.AddMonths(3)); 
    ApiSellerList.Sort = 2; 
    try 
    { 
     ItemTypeCollection oItems = ApiSellerList.GetSellerList(); 
     foreach (ItemType oItem in oItems) 
     { 
      Console.WriteLine("ItemID is " + oItem.ItemID); 
      Console.WriteLine("This item is of type " + oItem.ListingType.ToString()); 
      if (0 < oItem.SellingStatus.BidCount) 
      { 
       // The HighBidder element is valid only if there is at least 1 bid 
       Console.WriteLine("High Bidder is " + oItem.SellingStatus.HighBidder.UserID); 
      } 
      Console.WriteLine("Current Price is " + oItem.SellingStatus.CurrentPrice.currencyID.ToString() + " " + oItem.SellingStatus.CurrentPrice.Value.ToString()); 
      Console.WriteLine("End Time is " + oItem.ListingDetails.EndTime.ToLongDateString() + " " + oItem.ListingDetails.EndTime.ToLongTimeString()); 
      Console.WriteLine(""); 
      // the data that is accessible through the item object 
      // for different GranularityLevel and DetailLevel choices 
      // can be found at the following URL: 
      // http://developer.ebay.com/DevZone/SOAP/docs/WebHelp/GetSellerListCall-GetSellerList_Best_Practices.html 
     } 

    } 

    catch (ApiException oApiEx) 
    { 
     // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do 
     Console.WriteLine(oApiEx.Message); 
     return; 
    } 
    catch (SdkException oSdkEx) 
    { 
     // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do 
     Console.WriteLine(oSdkEx.Message); 
     return; 
    } 
    catch (Exception oEx) 
    { 
     // process exception ... pass to caller, implement retry logic here or in caller, whatever you want to do 
     Console.WriteLine(oEx.Message); 
     return; 
    } 
} 

#endregion  

に従うようです

スタックトレース: - eBay.Service.Core.Sdk.ApiCall.SendRequestで() eBay.Service.Core.Sdk.ApiCall.Execute(AT) eBay.Service.Call.GetSellerListCall.GetSellerList(AT)で

Nop.Services.EbayExport.ExportProducts.ConsumeAPIは()私は、生産セクションのキーを作成し、 「ApiContext.ApiCredential.eBayToken」のために

誰も使用してトークンを取得するには、「OAuthの アプリケーショントークンを取得する」をクリック.NetSDK eBay APIのために? 、私はあなたのコードに気づいた

+0

役立つかもしれないまあ、私は「Auth'n'auth」からトークンを取得した後、それを解決しました –

答えて

0

非常に最初のものは、あなたが使用しているAPIのバージョンである - 459

これは今、完全に廃止され、最低のeBayは、バージョンをサポート941

を更新してくださいされますバージョンと試してみてください。コードのバージョンを作業の下にあなた

https://ebaydts.com/eBayKBDetails?KBid=1686

関連する問題