Quickbooks Online沙盒返回等待激活,我有真正的Id,访问令牌

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Quickbooks Online沙盒返回等待激活,我有真正的Id,访问令牌相关的知识,希望对你有一定的参考价值。

我的代码如下: - 我不知道为什么我收到此消息,请帮忙。现在我正在使用沙盒帐户来测试这个。我已经生成了数据,即来自API资源管理器的示例数据,我将其作为参数传递给Json。

     public bool GeneratePayment(string JsonData)
        {
            var principal = User as ClaimsPrincipal;
            Session["realmId"] = "XXXXXX";
            if (Session["realmId"] != null)
            {
                string realmId = Session["realmId"].ToString();

                string qboBaseUrl = ConfigurationManager.AppSettings["QBOBaseUrl"];

                //add qbobase url and query
                string uri = string.Format("{0}/v3/company/{1}/invoice", qboBaseUrl, realmId);

                try
                {
                    var client = new HttpClient();


                    client.DefaultRequestHeaders.Add("Accept", "application/json;charset=UTF-8");
                    client.DefaultRequestHeaders.Add("ContentType", "application/json;charset=UTF-8");
                    client.DefaultRequestHeaders.Add("Authorization", "Bearer " + "XXXX");


//Here i am getting waiting for activation
                    var result = client.PostAsync(uri, new StringContent(JsonData, System.Text.Encoding.UTF8, "application/json"));

                    return true;
                }
                catch (Exception ex)
                {
                    return false;
                }
            }
            else
                return false;
        }
答案

Task相关的PostAsync有关。

GeneratePayment方法需要异步,client.PostAsync也需要等待

public async Task<bool> GeneratePayment(string JsonData) {
    var principal = User as ClaimsPrincipal;
    Session["realmId"] = "XXXXXX";
    if (Session["realmId"] != null) {
        string realmId = Session["realmId"].ToString();
        string qboBaseUrl = ConfigurationManager.AppSettings["QBOBaseUrl"];
        //add qbobase url and query
        string uri = string.Format("{0}/v3/company/{1}/invoice", qboBaseUrl, realmId);

        try {
            var client = http.Value; //singleton http client
            var result = await client.PostAsync(uri, new StringContent(JsonData, System.Text.Encoding.UTF8, "application/json"));
            return true;
        } catch (Exception ex) {
            return false;
        }
    }
    else
        return false;
}    

//Singleton lazy loaded HttpClieny
static Lazy<HttpClient> http = new Lazy<HttpClient>(() => {
    var client = new HttpClient();
    client.DefaultRequestHeaders.Add("Accept", "application/json;charset=UTF-8");
    client.DefaultRequestHeaders.Add("ContentType", "application/json;charset=UTF-8");
    client.DefaultRequestHeaders.Add("Authorization", "Bearer " + "XXXX");
    return client;
});

以上是关于Quickbooks Online沙盒返回等待激活,我有真正的Id,访问令牌的主要内容,如果未能解决你的问题,请参考以下文章

json QuickBooks Online V3 API OpenAPI

关于用Webservice连接QuickBooks Online实现于IOS App数据同步功能的个人记录

使用 QuickBooks Online (QBO) Intuit 合作伙伴平台 (IPP) DevKit 查询所有未结余额发票

当我使用适用于 .Net 的 V3 SDK 更新 QuickBooks Online 中的发票时,它没有效果

SharePoint 2013 沙盒解决方案不能激活(激活按钮不可用)

如何在Win10上激活Windows Sandbox沙盒功能