2013-03-03 27 views
1

,而試圖在Intuit公司使用過濾器我收到「未經授權」的錯誤給未經授權的錯誤:BillQuery用於獲取票據忒

異常詳細信息:Intuit.Ipp.E​​xception.InvalidTokenException:未經授權

下面的代碼被用於建立服務上下文:

string AppToken = ConfigurationManager.AppSettings["applicationToken"].ToString(CultureInfo.InvariantCulture); 
String realmId = HttpContext.Current.Session["realm"].ToString(); 
String accessToken = HttpContext.Current.Session["accessToken"].ToString(); 
String accessTokenSecret = HttpContext.Current.Session["accessTokenSecret"].ToString(); 
String consumerKey = ConfigurationManager.AppSettings["consumerKey"].ToString(CultureInfo.InvariantCulture); 
String consumerSecret = ConfigurationManager.AppSettings["consumerSecret"].ToString(CultureInfo.InvariantCulture); 
IntuitServicesType intuitServiceType = (IntuitServicesType)HttpContext.Current.Session["intuitServiceType"]; 

OAuthRequestValidator oauthValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, consumerKey, consumerSecret); 
context1 = new ServiceContext(oauthValidator, AppToken, realmId, IntuitServicesType.QBO); 

查詢檢索的最後修改帳單是如下:

List<Bill> CustomerBills = billQry.ExecuteQuery<Bill>(context1).ToList<Bill>(); 

請讓我知道,我通過錯誤的參數值。

回答

2

以下代碼.NET DevKit代碼發送格式錯誤的請求正文並導致OAuth簽名錯誤。這是DevKit中的一個錯誤。

BillQuery billQry = new BillQuery(); 
billQry.LastUpdatedTime = DateTime.Now.AddDays(-20); 
billQry.SpecifyOperatorOption(FilterProperty.LastUpdatedTime, FilterOperatorType.AFTER); 
billQry.LastUpdatedTime = DateTime.Now; 
billQry.SpecifyOperatorOption(FilterProperty.LastUpdatedTime, FilterOperatorType.BEFORE); 
billQry.PageNumber = 1; 
billQry.ResultsPerPage = 15; 
billQry.SpecifySortOption(SortProperty.LastUpdatedTime, SortOrderOption.HighToLow); 
List<Intuit.Ipp.Data.Qbo.Bill>CustomerBills =billQry.ExecuteQuery<Intuit.Ipp.Data.Qbo.Bill>(context).ToList(); 

解決方法是修改以下示例代碼以使請求和反序列化響應爲比爾對象。

Sample Code on Pastebin

+0

我也一樣,但仍面臨同樣的未經授權的問題。 – 2013-03-08 04:44:40

+2

您使用的是什麼版本的DevKit?另請發佈請求/響應XML(http://docs.developer.intuit.com/0025_Intuit_Anywhere/0200_DevKits/0100_IPP_.NET_DevKit/0600_Logging)。 – 2013-03-08 14:31:36

+0

您好,我正在使用IPP .NET DevKit 2.0請求XML篩選器= LastUpdatedTime:AFTER:2013-02-19T16:28:39 + 05:30:AND:LastUpdatedTime:BEFORE:2013-03-11T16:28:40 + 05 :30&Sort = LastUpdatedTime HighToLow&PageNum = 1&ResultsPerPage = 15響應XML:<?xml version =「1.0」encoding =「UTF-8」standalone =「yes」?>; 未經授權的OAuth令牌:signature_invalid SERVER 2013-03-11 11:03:48