0

我有一個需要將QuickBook API與我的web應用程序整合。我剛創建了一個示例應用程序來完成它。我很奇怪,我真的沒有任何關於如何連接api或消費api的想法。我提到了我從中取得的代碼(「https://developer.intuit.com/」)。 我嘗試通過在應用程序管理器中創建應用程序,我已經附加了圖像FYR。輸入所有這些細節後,我沒有獲得「accessTokenSecret」值。在這裏,我剛剛輸入了apptoken valuea作爲accessToken值。 Iam在服務上下文行中發現異常爲「未經授權」。幫我解決這個問題。如何在asp.net中使用快速預訂發票api

代碼:

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" }; 

     } 
    } 
} 

圖片:

QuickBook Api App Creation Image

回答

2

你應該檢查是否使用了正確的基礎URL https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0400_quickbooks_online/0100_calling_data_services/0010_getting_the_base_url

使用一些RESTCli ent [ex - Mozilla瀏覽器的RestClient插件],驗證OAuth令牌。 enter image description here

標題(內容類型)配置窗口。 enter image description here

您可以使用以下

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

您可以使用API​​Explorer工具測試所有這些API端點。

文檔 - https://developer.intuit.com/docs/0025_quickbooksapi/0010_getting_started/0007_firstrequest ApiExplorer - https://developer.intuit.com/apiexplorer?apiname=V2QBO

感謝

相關問題