QuickBooks Online API:新创建的客户已删除状态

时间:2015-07-18 17:14:56

标签: c# quickbooks-online

我遇到了一个问题,即我正在创建的项目被设置为已删除且未在QBO中显示。

这是我的代码:

OAuthRequestValidator oauthValidator = new OAuthRequestValidator(
                accessToken, accessTokenSecret, GetApiConsumerKey(), GetApiConsumerKeySecret());

ServiceContext context = new ServiceContext(GetApiAppToken(),
    realmID, IntuitServicesType.QBO, oauthValidator);
context.IppConfiguration.BaseUrl.Qbo = "https://sandbox-quickbooks.api.intuit.com/";
context.IppConfiguration.Message.Request.SerializationFormat = SerializationFormat.Json;
context.IppConfiguration.Message.Response.SerializationFormat = SerializationFormat.Json;

DataService dataService = new DataService(context);

Customer customer = new Customer();
customer.Active = true;
customer.GivenName = "Test";
customer.DisplayName = "Test";
customer.WebAddr = new WebSiteAddress();
customer.WebAddr.URI = "http://www.google.com";

customer = dataService.Add<Customer>(customer);

if (customer.status == EntityStatusEnum.Deleted)
{
    // Gets to here every time.
}

任何人都可以看到这里可能出现的问题会导致每个创建的实体被删除吗?我也无法在QBO UI中使用搜索找到它们。

修改

根据要求,我正在添加发送/接收的JSON数据:

{// Sent JSON
    "GivenName":"Martin",
    "FamilyName":"Noreke",
    "DisplayName":"Martin Noreke",
    "WebAddr":{"URI":"http://www.google.com"}
}

{// Received JSON
  "Customer":{
    "Taxable":true,
    "Job":false,
    "BillWithParent":false,
    "Balance":0,
    "BalanceWithJobs":0,
    "CurrencyRef":{"value":"USD","name":"United States Dollar"},
    "PreferredDeliveryMethod":"Print",
    "domain":"QBO",
    "sparse":false,
    "Id":"68",
    "SyncToken":"0",
    "MetaData":{"CreateTime":"2015-07-19T08:25:22-07:00","LastUpdatedTime":"2015-07-19T08:25:22-07:00"},
    "GivenName":"Martin",
    "FamilyName":"Noreke",
    "FullyQualifiedName":"Martin Noreke",
    "DisplayName":"Martin Noreke",
    "PrintOnCheckName":"Martin Noreke",
    "Active":true,
    "WebAddr":{"URI":"http://www.google.com"},
    "DefaultTaxCodeRef":{"value":"2"}},
    "time":"2015-07-19T08:25:22.958-07:00"
 }      

从JSON开始,它似乎正在正确地创建客户。但是,我无法在我连接的沙箱帐户中找到它。

1 个答案:

答案 0 :(得分:1)

这是我发布关于我没有注意的自贬故事的地方。

在使用API​​时,我以某种方式创建了第二家公司。即使点击第一家公司,Intuit也会记得你的最后一家公司并直接带你去那里。

使用齿轮菜单切换公司,让我可以找到合适的公司,以便查看我创建的数据。

我现在觉得很傻......:/