0

我需要将 Quickbook api 与我的 Web 应用程序集成在一起。我刚刚创建了一个示例应用程序来完成它。我对此感到奇怪,我真的不知道如何连接 api 或使用 api。我提到了我从(“ https://developer.intuit.com/ ”)获取的代码。我尝试在应用程序管理器中创建一个应用程序,我已附上图像 FYR。输入所有这些详细信息后,我没有得到“accessTokenSecret”值。在这里,我刚刚输入了 apptoken valuea 作为 accessToken 值。我在服务上下文行中收到“未经授权”的异常。帮我解决这个问题。

代码:

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 应用创建图片

4

1 回答 1

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 [ ex - Mozilla 浏览器的 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

谢谢

于 2013-10-04T13:19:28.857 回答