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

本文关键字:SDK NET V3 更新 客户 IPP QBO Id 何使用 SyncToken | 更新日期: 2023-09-27 17:59:14

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

出现错误(您和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);

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

在对任何对象进行任何更新之前,您应该使用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()_方法

类似的问题参考-快速预订错误你和山姆在同一时间工作

感谢

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

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