简体   繁体   English

在QBO API 3中更新客户

[英]Update A Customer in QBO API 3

I have tried this however now I am getting a bad request. 我已经尝试过了,但是现在我收到了一个错误的请求。

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

There is currently a bug in Dotnet SDK for Customer Update where the incorrect namespaces cause the request to error out. Dotnet SDK for Customer Update当前存在一个错误,其中错误的名称空间会导致请求出错。 We are working on that. 我们正在努力。 Check this workaround: 检查以下解决方法:

Create a new Customer object and assign the result to it. 创建一个新的Customer对象并将结果分配给它。 Then call Customer update operation. 然后致电客户更新操作。 Eg: 例如:

Customer found = GetQboCustomer(); 
Customer customerToUpdate = new Customer(); 
customerToUpdate.Id = found.Id; 
customerToUpdate.SyncToken = found.SyncToken; 
//Set Other Properties 
//Perform Sparse Update
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;
}

You were about to get some customers list and again finding by id then updating the old, that wont be fine, u can do like above or the best way i believe is below. 您将要获得一些客户列表,并再次通过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;
}

You can try to capture the raw request and response XMLs related to this update API call. 您可以尝试捕获与此更新API调用相关的原始请求和响应XML。 Ref - https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0150_ipp_.net_devkit_3.0/logging#Request_and_Response_Log 参考-https: //developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0150_ipp_.net_devkit_3.0/logging#Request_and_Response_Log

You can also try to create the customer update payload and try the update call using Apiexplorer. 您也可以尝试创建客户更新有效负载,并尝试使用Apiexplorer进行更新调用。 https://developer.intuit.com/apiexplorer?apiname=V3QBO#Customer https://developer.intuit.com/apiexplorer?apiname=V3QBO#Customer

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM