1

尝试在 Intuit 中使用过滤器时出现“未经授权”错误:

异常详细信息: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>();

请告诉我,我传递的参数值不正确。

4

1 回答 1

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();

解决方法是修改下面的示例代码以发出请求并将响应反序列化为 Bill 对象。

Pastebin 上的示例代码

于 2013-03-04T18:47:42.650 回答