[已解决] 看来“显示为”字段是不可更新的字段。当我们使用其他字段时,它可以完美运行。
我今天刚开始使用 QB API V2 for QB Enterprise。我正在学习如何使用 ASP.NET Webform 进行添加/更新/查看/删除操作。我在这里从 QB 下载了示例https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/sample_code
我可以看到我的公司列表。现在我尝试从下面的代码更新公司字段,它没有更新,也没有给我任何错误。谁能看看我是否错过了什么?
appToken = ConfigurationManager.AppSettings["applicationToken"];
realmId = HttpContext.Current.Session["realm"].ToString();
accessToken = HttpContext.Current.Session["accessToken"].ToString();
accessTokenSecret = HttpContext.Current.Session["accessTokenSecret"].ToString();
consumerKey = ConfigurationManager.AppSettings["consumerKey"].ToString(CultureInfo.InvariantCulture);
consumerSecret = ConfigurationManager.AppSettings["consumerSecret"];
dataSourcetype = HttpContext.Current.Session["dataSource"].ToString().ToLower() == "qbd" ? IntuitServicesType.QBD : IntuitServicesType.QBO;
OAuthRequestValidator oauthValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, consumerKey, consumerSecret);
ServiceContext context = new ServiceContext(oauthValidator, appToken, realmId, dataSourcetype);
DataServices commonService = new DataServices(context);
var qbdCustomerQuery = new Intuit.Ipp.Data.Qbd.CustomerQuery();
qbdCustomerQuery.ItemElementName = Intuit.Ipp.Data.Qbd.ItemChoiceType4.StartPage;
qbdCustomerQuery.Item = "1";
qbdCustomerQuery.ChunkSize = "10";
var qbdCustomers = qbdCustomerQuery.ExecuteQuery<Intuit.Ipp.Data.Qbd.Customer>(context).ToList();
Intuit.Ipp.Data.Qbd.Customer bb = qbdCustomers.FirstOrDefault();
bb.ShowAs = "TTTTT";
Intuit.Ipp.Data.Qbd.Customer bbUpdate = commonService.Update(bb) as Intuit.Ipp.Data.Qbd.Customer;
我启用了日志,这是请求和响应。
要求
<?xml version="1.0" encoding="utf-8"?><Mod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" RequestId="07e1d63eae654991aca3438ff787b6f4" FullResponse="true" xmlns="http://www.intuit.com/sb/cdm/v2"><ExternalRealmId>832118285</ExternalRealmId><Object xsi:type="Customer"><Id idDomain="QB">1</Id><SyncToken>3</SyncToken><MetaData><CreatedBy>app</CreatedBy><CreateTime>2013-11-05T19:03:18Z</CreateTime><LastModifiedBy>app</LastModifiedBy><LastUpdatedTime>2013-11-05T19:06:21Z</LastUpdatedTime></MetaData><ExternalKey>1001741590</ExternalKey><Synchronized>false</Synchronized><PartyReferenceId idDomain="QB">1</PartyReferenceId><TypeOf>Person</TypeOf><Name>Samurai</Name><Address><Id>2213595</Id><Line1>Samurai</Line1><Line2>Samu Rai</Line2><Default>true</Default><Tag>Billing</Tag></Address><Phone><Id>1317517</Id><DeviceType>LandLine</DeviceType><FreeFormNumber>111-111-1111</FreeFormNumber><Default>true</Default><Tag>Business</Tag></Phone><Email><Id>603369</Id><Address>samu@gmail.com</Address><Default>true</Default><Tag>Business</Tag></Email><Title>Mr.</Title><GivenName>Samu</GivenName><FamilyName>Rai</FamilyName><DBAName>Samurai</DBAName><Active>true</Active><ShowAs>TTTTT</ShowAs><OpenBalance><CurrencyCode>USD</CurrencyCode><Amount>0</Amount></OpenBalance><JobInfo><Status>None</Status></JobInfo></Object></Mod>
回复
<?xml version="1.0" ?><RestResponse xmlns="http://www.intuit.com/sb/cdm/v2"><Success RequestId="07e1d63eae654991aca3438ff787b6f4"><Customer><Id idDomain="QB">1</Id><SyncToken>4</SyncToken><MetaData><CreatedBy>app</CreatedBy><CreateTime>2013-11-05T19:03:18Z</CreateTime><LastModifiedBy>app</LastModifiedBy><LastUpdatedTime>2013-11-05T19:11:33Z</LastUpdatedTime></MetaData><ExternalKey idDomain="NG">1001741590</ExternalKey><Synchronized>false</Synchronized><PartyReferenceId idDomain="QB">1</PartyReferenceId><TypeOf>Person</TypeOf><Name>Samurai</Name><Address><Id idDomain="NG">2213620</Id><Line1>Samurai</Line1><Line2>Samu Rai</Line2><Default>true</Default><Tag>Billing</Tag></Address><Phone><Id idDomain="NG">1317538</Id><DeviceType>LandLine</DeviceType><FreeFormNumber>111-111-1111</FreeFormNumber><Default>true</Default><Tag>Business</Tag></Phone><Email><Id idDomain="NG">603372</Id><Address>samu@gmail.com</Address><Default>true</Default><Tag>Business</Tag></Email><Title>Mr.</Title><GivenName>Samu</GivenName><FamilyName>Rai</FamilyName><DBAName>Samurai</DBAName><Active>true</Active><ShowAs>Samurai</ShowAs><OpenBalance><CurrencyCode>USD</CurrencyCode><Amount>0</Amount></OpenBalance><JobInfo><Status>None</Status></JobInfo></Customer><RequestName>CustomerMod</RequestName><ProcessedTime>2013-11-05T19:11:33Z</ProcessedTime></Success></RestResponse>
我看到它从请求中为“Show As”字段发送了“TTTTT”,但响应显示旧值“Samurai”
我在 QBD 的 API Explorer 中粘贴了请求,下面是响应。不确定错误是什么意思。
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2"><Error RequestId="07e1d63eae654991aca3438ff787b6f4">
<RequestName>ErrorRequest</RequestName>
<ProcessedTime>2013-11-05T19:22:23.372Z</ProcessedTime>
<ErrorCode>-3002</ErrorCode>
<ErrorDesc>unique constraint (ESB.PTYAPI_IDX_RID) violated</ErrorDesc>
<DBErrorCode>00001</DBErrorCode>