2013-03-03 65 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