首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >IPP添加帐户-帐户无效

IPP添加帐户-帐户无效
EN

Stack Overflow用户
提问于 2013-05-09 03:09:56
回答 1查看 130关注 0票数 1

我正在尝试添加一个银行帐户到QuickBooks在线使用IPP。我的代码失败,并显示帐户无效。下面是我的代码:

代码语言:javascript
复制
            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:

代码语言:javascript
复制
            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请求:

代码语言:javascript
复制
<?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>

以下是我的回应:

代码语言:javascript
复制
<?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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-10 05:08:25

我需要使用真实变量指定期初余额和当前余额:

代码语言:javascript
复制
            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。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16448391

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档