1

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

"EntityManager must be access within a transaction"

谷歌搜索错误消息会发现一些关于 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);

感谢您提供的任何建议!

4

3 回答 3

0

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

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

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

同步调用文档参考 - https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0100_ipp_.net_devkit/0299_synchronous_calls/0001_data_service_apis

异步调用文档参考 - https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0100_ipp_.net_devkit/0300_asynchronous_calls/0001_data_service_apis

希望这些会有用

您可以使用客户实体的普通设置器进行检查吗?

于 2013-07-11T19:04:53.347 回答
0

附上示例代码供您参考:在此处输入图像描述

于 2013-07-19T08:00:53.917 回答
0

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

请更正这一点。使用正确的库 Intuit.Ipp.Data.Qbo

于 2013-07-12T16:27:38.210 回答