如何使用Id,SyncToken为QBO IPP .NET SDK V3更新客户?

时间:2014-04-21 11:29:10

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

如何使用Id,SyncToken为QBO IPP .NET SDK V3更新客户?

得到一个错误(你和admin@gmail.com同时正在处理这个问题.ajoshi @ varstreet.com在你做之前完成了,所以你的工作没有保存。)

请建议我哪里出错了。

                IdType CustID = new IdType();
                CustID.Value = "22";

                var NewqboCustomer = new Customer()
                {


                    Id = CustID,
                    SyncToken = "0",

                    // Display name as Customer Name
                    Name = "Name",
                    ShowAs = "Name", //Print on check 

                    //                                

                    //Contact Info 
                    Title = "",
                    GivenName = "Contact1",
                    MiddleName = "",
                    FamilyName = "Contact1",
                    //   

                    //Notes ="Notes ",


                    Notes = new Note[]
                            {
                                new Note()
                                {                                        
                                    Content ="Test Notes",

                                }

                            },

                    TypeOf = partyType.Organization,

                    Address = new PhysicalAddress[]
                            {
                                new PhysicalAddress()
                                    {
                                        Line1 = "bill Line 1",
                                        Line2 = "Bill Line 2",
                                        Line3 =  "Bill Line 3",
                                        Line4 =  "Bill Line 4",
                                        Line5 =  "Bill Line 5",
                                        City = " Bill City ",
                                        Country ="Bill Country",
                                        CountyCode ="Bill Counrty code",
                                        CountrySubDivisionCode = "NC",
                                        PostalCode = "55712",
                                        PostalCodeSuffix="Postal Code Suffix",
                                        Tag = new string[]{"Billing"}
                                    },

                                     new PhysicalAddress()
                                    {
                                        Line1 = "Ship Line 11",
                                        Line2 = "Ship Line 21",
                                        Line3 =  "Ship Line 3",
                                        Line4 =  "Ship Line 4",
                                        Line5 =  "Ship Line 5",
                                        City =    "Ship City ",
                                        Country ="Ship Country",
                                        CountyCode ="Ship Counrty code",
                                        CountrySubDivisionCode = "NC",
                                        PostalCode = "55712",
                                        PostalCodeSuffix="Shippf",
                                        Tag = new string[]{"Shipping"}
                                    }                                       


                            },

                    Phone = new TelephoneNumber[]
                            {
                                new TelephoneNumber()
                                {
                                    DeviceType = "Work",
                                    FreeFormNumber = "111-345-3456"
                                },
                                new TelephoneNumber()
                                {
                                    DeviceType = "Mobile",
                                    FreeFormNumber = "111-345-3457"
                                },
                                new TelephoneNumber()
                                {
                                    DeviceType = "Fax",
                                    FreeFormNumber = "111-345-3457"
                                }
                            },

                    WebSite = new WebSiteAddress[]
                            {
                                new WebSiteAddress()
                                {
                                    URI = "http://www.varstreet.com"
                                }
                            },

                    Email = new EmailAddress[]
                            {
                                new EmailAddress()
                                {
                                    Address = "india@varstreet.com"
                                }
                            },

                    SalesTermId = new IdType()
                    {
                        //idDomain = idDomainEnum.QBO, 
                        //Value = "8" 
                    },


                };

                var output = commonService.Update(NewqboCustomer);

2 个答案:

答案 0 :(得分:2)

在对任何对象进行任何更新之前,您应该使用findById调用查询该对象以获取最新的syncToken。请在下次更新通话中使用最新的同步令牌。 它将解决这个问题。

GetById参考 - https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0150_ipp_.net_devkit_3.0/0002_synchronous_calls/0001_data_service_apis#FindById()_Method

类似问题参考 - Quick Book Error You and sam working on this at the same time

谢谢

答案 1 :(得分:0)

除非您在更新之前进行读取,否则元数据是陈旧的/不是最新的。 因此,如果您尝试对此进行更新,则会收到与该对象相关的冲突元数据的错误。 一旦您执行读取并且您的对象具有最新元数据,您就可以成功更新对象。 syncToken可能/可能不会改变,但元数据会改变。因此,需要在更新之前刷新它以及同步令牌。

<MetaData>
<CreateTime>2013-04-23T18:10:52-07:00</CreateTime>
<LastUpdatedTime>2013-04-23T18:10:52-07:00</LastUpdatedTime>
</MetaData>