尝试插入客户时收到错误

时间:2013-07-11 18:54:26

标签: quickbooks intuit-partner-platform

我正在尝试使用QuickBooks .NET REST API v2库创建客户。在调用dataservice对象的Add()方法来提交请求时,我收到一条我不理解的错误消息:

"EntityManager must be access within a transaction"

Google搜索错误消息会对Java产生一些点击,但没有一个看起来真的解决了这个问题,也没有在Intuit-Partner-Platform文档中找到有关该消息的任何文档。

using Intuit.Ipp.Data.Qbd;

            OAuthRequestValidator oauthValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, Constants.CONSUMER_KEY, Constants.CONSUMER_SECRET);
            ServiceContext context = new ServiceContext(oauthValidator, Constants.APP_TOKEN, realmID, IntuitServicesType.QBD);
            DataServices dataServices = new DataServices(context);


            var writeCust = new Customer()
            {
                Name = "Carlos Verdona",
                TypeOf = partyType.Person,
                Address = new PhysicalAddress[]
                {
                    new PhysicalAddress()
                        {
                            Line1 = "217 Tarboro Highway",
                            Line2 = "Apt. D",
                            City = "Langleyville",
                            CountrySubDivisionCode = "NC",
                            PostalCode = "55712",
                            Tag = new string[]{"Billing"}
                        }
                },
                Phone = new TelephoneNumber[]
                {
                    new TelephoneNumber()
                    {
                        DeviceType = "Work",
                        FreeFormNumber = "111-345-3456"
                    },
                    new TelephoneNumber()
                    {
                        DeviceType = "Mobile",
                        FreeFormNumber = "111-345-3457"
                    }
                },
                WebSite = new WebSiteAddress[]
                {
                    new WebSiteAddress()
                    {
                        URI = "http://www.HorseBrains.com"
                    }
                },
                Email = new EmailAddress[]
                {
                    new EmailAddress()
                    {
                        Address = "CVerdona@HorseBrains.com"
                    }
                },
                GivenName = "",
                MiddleName = "",
                FamilyName = "",
                DBAName = "",
                ShowAs = "Carlos Verdona",
                //CustomField = new CustomField[]
                //{
                //    new BooleanTypeCustomField()
                //    {
                //        DefinitionId =  "Bill With Parent",
                //        Value = true
                //    },
                //    new StringTypeCustomField()
                //    {
                //        DefinitionId = "Preferred Delivery Method",
                //        Value = "PRINT"
                //    }

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

            };

            //Create Customer
            Customer output = dataServices.Add(writeCust);

感谢您提供任何建议!

3 个答案:

答案 0 :(得分:0)

请尝试通过直接调用“创建客户”端点来创建客户对象的Apiexploer工具。 https://developer.intuit.com/apiexplorer?apiName=V2QBO

您也可以参考以下docs API和.Net devkit链接。

API文档 - https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0400_quickbooks_online/customer

同步通话doc ref - https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0100_ipp_.net_devkit/0299_synchronous_calls/0001_data_service_apis

Asyn致电doc ref - https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0100_ipp_.net_devkit/0300_asynchronous_calls/0001_data_service_apis

希望这些有用

您可以使用Customer实体的普通设置器进行检查。

答案 1 :(得分:0)

我注意到你正在引用Intuit.Ipp.Data.Qbd;因此,为QBD创建了客户对象。然后在最后几行中,您将id域作为QBO传递: SalesTermId = new IdType(){idDomain = idDomainEnum.QBO,Value =“8”},

请更正此信息。 使用正确的库Intuit.Ipp.Data.Qbo

答案 2 :(得分:0)

附上示例代码供您参考:enter image description here