IPP添加帐户 - 帐户无效
问题描述:
我正尝试使用IPP向QuickBooks Online添加银行帐户。我的代码失败,并说该帐户无效。这是我的代码:IPP添加帐户 - 帐户无效
Account account = new Account();
account.Desc = "Desc";
account.Name = "Checking2";
account.Type = AccountTypeEnum.Revenue;
account.TypeSpecified = true;
account.Subtype = AccountSubtypeEnum.Bank.ToString();
dataServices.Add(account);
是否需要添加字段?我还收到存在同名帐户的错误,但是,我没有看到它。
我没有看到我日志中的任何XML:
OAuthRequestValidator oauthValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, ConfigurationManager.AppSettings["consumerKey"].ToString(), ConfigurationManager.AppSettings["consumerSecret"].ToString());
ServiceContext context = new ServiceContext(oauthValidator, accessToken, companyID, IntuitServicesType.QBO);
context.EnableServiceRequestsLogging = true;
context.IdsLogger = new MyCustomLogger();
dataServices = new DataServices(context);
return "OK";
public class MyCustomLogger : ILogger
{
public MyCustomLogger()
{
}
public string ClearLog()
{
try
{
string path = HttpContext.Current.Server.MapPath("/qblog.txt");
if (File.Exists(path))
{
File.Delete(path);
}
return "OK";
}
catch (Exception ex)
{
return ex.ToString();
}
}
public void Log(TraceLevel idsTraceLevel, string messageToWrite)
{
string level = idsTraceLevel.ToString();
WriteToLog(new ErrorMessage(MessageSeverity.Error, "QBFS", messageToWrite));
}
public string WriteToLog(ErrorMessage message)
{
if (!String.IsNullOrEmpty(message.Message))
{
string path = HttpContext.Current.Server.MapPath(HttpContext.Current.Request.ApplicationPath + "/qblog.txt");
FileStream fileStream = null;
//If the file exists, then append it
if (File.Exists(path))
{
fileStream = new FileStream(path, FileMode.Append);
}
else
{
fileStream = new FileStream(path, FileMode.OpenOrCreate);
}
StreamWriter sw = new StreamWriter(fileStream);
try
{
sw.WriteLine(String.Format("{0} : {1} {2} {3}", message.ApplicationName, message.Severity, DateTime.Now, message.Message));
return "OK";
}
//If there is an error, just do nothing. Don't stop.
catch (Exception ex)
{
return ex.ToString();
}
finally
{
sw.Close();
fileStream.Close();
}
}
return "Message is null or empty";
}
}
这里是我的XML请求:
<?xml version="1.0" encoding="utf-8"?><q1:Account xmlns="http://www.intuit.com/sb/cdm/qbo" xmlns:q1="http://www.intuit.com/sb/cdm/v2"><q1:Name>Checking</q1:Name><q1:Desc>Desc</q1:Desc><q1:Subtype>Bank</q1:Subtype></q1:Account>
这里是我的回应:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><FaultInfo xmlns="http://www.intuit.com/sb/cdm/baseexceptionmodel/xsd"><Message>Another account is already using this name. Please use a different name.</Message><ErrorCode>BAD_REQUEST</ErrorCode><Cause>-11202</Cause></FaultInfo>
答
我需要指定开放和curre nt与真实变量的平衡:
ac = new Account();
ac.Desc = "Desc";
ac.Name = "Testy";
ac.Subtype = QboAccountDetailTypeEnum.Checking.ToString();
ac.OpeningBalanceDate = DateTime.Now;
ac.OpeningBalanceDateSpecified = true;
ac.CurrentBalance = 0;
ac.CurrentBalanceSpecified = true;
dataServices.Add(ac);
我的子类型也是不正确的。我需要使用QboAccountDetailTypeEnum。
请记录请求/回应:http://ippdocs.intuit.com/0025_QuickBooksAPI/0055_DevKits/0100_IPP_.NET_DevKit/0600_Logging QBO帐户中没有类型,只有SubType。请参阅:http://ippdocs.intuit.com/0025_QuickBooksAPI/0050_Data_Services/v2/0400_QuickBooks_Online/Account – 2013-05-08 19:17:47
谢谢,但我在哪里可以看到XML?它不在qblog.txt或SDKTraceLog.log中 – 2013-05-08 19:38:46
请启用将它们写入磁盘的请求/响应日志。 http://ippdocs.intuit.com/0025_QuickBooksAPI/0055_DevKits/0100_IPP_.NET_DevKit/0600_Logging#Request_and_Response_Log – 2013-05-08 19:43:09