Quickbooks Online 沙箱 returns 等待激活,我有真实 ID,访问令牌

Quickbooks Online sandbox returns Waiting for Activation, i have realmId, accesstoken aswell

我的代码如下:- 我不知道为什么我会收到此消息,请帮忙。现在 我正在使用沙盒帐户对此进行测试。我已经生成了数据,即来自 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;
        }

PostAsync 关联的 Task 有关。

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