在QBO API 3中更新客户

时间:2014-06-04 13:23:27

标签: c# intuit-partner-platform quickbooks-online

我试过这个但是现在我得到了一个糟糕的请求。

var customers = IntuitServiceConfig.ServiceManager.FindAll<Customer>(new Customer(), 1, 100); 

foreach (Intuit.Ipp.Data.Customer customer in customers)
{
    Customer resultCustomer = IntuitServiceConfig.ServiceManager.FindById(customer) as Customer;

    //Mandatory Fields
    customer.Id = resultCustomer.Id;
    customer.SyncToken = resultCustomer.SyncToken;
    customer.GivenName = "Bob";
    customer.Title = "Mr.";
    customer.MiddleName = "Anto";
    customer.FamilyName = "Bob";

    Customer result = IntuitServiceConfig.ServiceManager.Update(customer) as Customer;
}

3 个答案:

答案 0 :(得分:2)

Dotnet SDK for Customer Update目前存在一个错误,其中不正确的命名空间导致请求错误输出。 我们正在努力。 检查此解决方法:

创建一个新的Customer对象并将结果分配给它。然后调用客户更新操作。 例如:

Customer found = GetQboCustomer(); 
Customer customerToUpdate = new Customer(); 
customerToUpdate.Id = found.Id; 
customerToUpdate.SyncToken = found.SyncToken; 
//Set Other Properties 
//Perform Sparse Update

答案 1 :(得分:2)

var customers = IntuitServiceConfig.ServiceManager.FindAll<Customer>(new Customer(), 1, 100); 
foreach (Intuit.Ipp.Data.Customer customer in customers)
{
    Customer resultCustomer = IntuitServiceConfig.ServiceManager.FindById(customer) as Customer;

    //Mandatory Fields
    resultCustomer.GivenName = "Bob";
    resultCustomer.Title = "Mr.";
    resultCustomer.MiddleName = "Anto";
    resultCustomer.FamilyName = "Bob";

    Customer result = IntuitServiceConfig.ServiceManager.Update(resultCustomer) as Customer;
}

您即将获得一些客户列表并再次通过ID查找然后更新旧的,不会很好,您可以像上面那样做,或者我认为最好的方式在下面。

var customers = IntuitServiceConfig.ServiceManager.FindAll<Customer>(new Customer(), 1, 100); 
foreach (Intuit.Ipp.Data.Customer customer in customers)
{
    //Mandatory Fields
    customer.GivenName = "Bob";
    customer.Title = "Mr.";
    customer.MiddleName = "Anto";
    customer.FamilyName = "Bob";

    Customer result = IntuitServiceConfig.ServiceManager.Update(customer) as Customer;
}

答案 2 :(得分:0)

您可以尝试捕获与此更新API调用相关的原始请求和响应XML。 参考 - https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0150_ipp_.net_devkit_3.0/logging#Request_and_Response_Log

您还可以尝试使用Apiexplorer创建客户更新有效负载并尝试更新调用。 https://developer.intuit.com/apiexplorer?apiname=V3QBO#Customer

由于