IPP .NET SDK QuickBooks的V3.0创建发票错误 - 错误的请求 [英] IPP .NET SDK for QuickBooks v3.0 Create Invoice Error - Bad Request

查看:181
本文介绍了IPP .NET SDK QuickBooks的V3.0创建发票错误 - 错误的请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个很难搞清楚究竟是怎么回事错在这里 - 我没有得到很多有识之士形成错误错误的请求 - 这是我的code:

I am having a hard time figuring out what exactly is going wrong here - I do not get alot of insight form the error Bad Request - here is my code:

OAuthRequestValidator oauthValidator = new OAuthRequestValidator(accessToken, accessTokenSecret, consumerKey, consumerSecret);
                ServiceContext context = new ServiceContext(appToken, companyID, IntuitServicesType.QBO, oauthValidator);

                DataService service = new DataService(context);
                Customer customer = new Customer();
                customer.GivenName = "Mary " + DateTime.Now.Second;
                customer.Title = "Ms.";
                customer.MiddleName = "Jayne";
                customer.FamilyName = "Cooper";
                customer.CompanyName = "Mary " + DateTime.Now.Second;
                Customer resultCustomer = service.Add(customer) as Customer;

                Invoice invoice = new Invoice();
                //Mandatory fields
                invoice.DocNumber = Guid.NewGuid().ToString("N").Substring(0, 10);
                invoice.TxnDate = DateTime.Today.Date;
                invoice.TxnDateSpecified = true;
                invoice.CustomerRef = new ReferenceType()
                {
                     Value = resultCustomer.Id
                };

                Line invLine = new Line();

                invLine.Amount = 10000;
                invLine.DetailType = LineDetailTypeEnum.SalesItemLineDetail;
                invLine.Description = "Test Product";

                invoice.Line = new Line[] { invLine };

               Invoice resutlInvoice = service.Add(invoice) as Invoice;

                var invId = resutlInvoice.Id;

基本上我生成一个新的客户(其中正常工作),然后我想在其上为他们创造了单个项目的发票。

Basically I am generating a new customer (which work fine) and then I am trying to create an invoice for them with a single item on it.

看什么XML的文档指出在这里:
<一href=\"http://ippdocs.intuit.com/0025_QuickBooksAPI/0050_Data_Services/V3/030_Entity_Services_Reference/Invoice\" rel=\"nofollow\">http://ippdocs.intuit.com/0025_QuickBooksAPI/0050_Data_Services/V3/030_Entity_Services_Reference/Invoice

Looking at what XML the documentation states here: http://ippdocs.intuit.com/0025_QuickBooksAPI/0050_Data_Services/V3/030_Entity_Services_Reference/Invoice

该包的NuGet缺少了一些东西,我知道不能是真实的 - 形成文档:

The NuGet package is missing a few things, which I know cant be true - form the documentation:

<Invoice xmlns="http://schema.intuit.com/finance/v3">
  <Line>
    <Amount>15</Amount>
    <DetailType>SalesItemLineDetail</DetailType>
    <SalesItemLineDetail>
      <ItemRef>1</ItemRef>
    </SalesItemLineDetail>
  </Line>
  <CustomerRef>67</CustomerRef>
</Invoice>

对象我从这个SDK获取对SalesItemLineDetail或没有的itemref的属性就可以了。

The Line object I get from this SDK has no properties for SalesItemLineDetail or ItemRef on it.

任何人都有这样一个工作的例子吗?

Anyone have a working example of this?

推荐答案

这就是.NET的devkit从Java 1不同的领域之一。

This is one of the areas where the .NET devkit differs from the Java one.

您必须设置 AnyIntuitObject 属性设置为SalesItemLineDetail,然后 DetailType 属性设置为 LineDetailTypeEnum.SalesItemLineDetail

You have to set the AnyIntuitObject property to the SalesItemLineDetail and then set the DetailType property to LineDetailTypeEnum.SalesItemLineDetail".

有周围的框架,出现这样的一些点点滴滴。

There's a few bits and pieces around the framework that appear like this.

下面是一个简短的样本,虽然基于注释是的的使用最新的SDK。

Here's a short sample, although based on the comments it is not using the latest SDK.

Line l = new Line()
{
    l.AnyIntuitObject = new SalesItemLineDetail()
    {
        ItemElementName = ItemChoiceType.UnitPrice,
        AnyIntuitObject = amount,
        ...
    },
    DetailType = LineDetailTypeEnum.SalesItemLineDetail,
    ...
}

这篇关于IPP .NET SDK QuickBooks的V3.0创建发票错误 - 错误的请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆