我需要将Quickbook api与我的Web应用程序集成。我刚刚创建了一个示例应用程序来完成它。我对此很奇怪我真的不知道如何连接api或消费api。我已经提到了我从(“https://developer.intuit.com/”)获取的代码。 我尝试在应用程序管理器中创建一个应用程序,我已经附加了图像FYR。输入所有这些细节后,我没有得到“accessTokenSecret”值。在这里,我刚刚输入了apptoken valuea作为accessToken值。我在服务上下文行中获得异常为“Unauthorized”。帮助我。
代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Intuit.Ipp.Core;
using Intuit.Ipp.Services;
using Intuit.Ipp.Data;
using Intuit.Ipp.Utility;
using Intuit.Ipp.Security;
using Intuit.Ipp.Data.Qbo;
using Newtonsoft.Json;
namespace QuickBookApiConsumption
{
public partial class Invoice : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnsendInvoiceDetails_Click(object sender, EventArgs e)
{
string accessToke = "";
string appToken = "297db54bb5526b494dba97fb2a41063192cd";
string accessTokenSecret = "297db54bb5526b494dba97fb2a41063192cd";
string consumerKey = "qyprdMSG1YHpCPSlWQZTiKVc78dywR";
string consumerSecret = "JPfXE17YnCPGU9m9vuXkF2M765bDb7blhcLB7HeF";
string companyID = "812947125";
OAuthRequestValidator oauthValidator = new OAuthRequestValidator(appToken, accessTokenSecret, consumerKey, consumerSecret);
ServiceContext context = new ServiceContext(oauthValidator, appToken, companyID, IntuitServicesType.QBO);
DataServices service = new DataServices(context);
Invoice os = new Invoice();
Intuit.Ipp.Data.Qbo.InvoiceHeader o = new Intuit.Ipp.Data.Qbo.InvoiceHeader();
o.CustomerName = "Viki";
o.CustomerId = new Intuit.Ipp.Data.Qbo.IdType { Value = "12" };
o.ShipMethodName = "Email";
o.SubTotalAmt = 3.00m;
o.TotalAmt = 6.00m;
o.ShipAddr = new Intuit.Ipp.Data.Qbo.PhysicalAddress { City = "Chni" };
}
}
}
图片:
答案 0 :(得分:2)
您应该检查您是否使用了正确的BASE URL https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0400_quickbooks_online/0100_calling_data_services/0010_getting_the_base_url
使用一些RESTClient [Mozilla浏览器的ex-RestClient插件],验证OAuth令牌。
标题(内容类型)配置窗口。
您可以使用以下
public void ConnectUsingAuth()
{
string accessToken = ConfigurationManager.AppSettings["AccessTokenQBD"];
string accessTokenSecret = ConfigurationManager.AppSettings["access-secret"];
string consumerKey = ConfigurationManager.AppSettings["consumerKey"];
string consumerKeySecret = ConfigurationManager.AppSettings["consumerSecret"];
string URI = "https://apiend-point";
WebRequest webRequest = WebRequest.Create(URI);
webRequest.Headers.Add("ContentType", "text/xml");
OAuthRequestValidator target = new OAuthRequestValidator(accessToken, accessTokenSecret, consumerKey, consumerKeySecret);
}
或 [更好的选择]您可以从github下载示例程序并配置web.config(使用正确的消费者密钥和密钥)
https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/sample_code
您可以使用APIExplorer工具测试所有这些API端点。
文档 - https://developer.intuit.com/docs/0025_quickbooksapi/0010_getting_started/0007_firstrequest ApiExplorer - https://developer.intuit.com/apiexplorer?apiname=V2QBO
谢谢