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.
Looking at what XML the documentation states here:
http://ippdocs.intuit.com/0025_QuickBooksAPI/0050_Data_Services/V3/030_Entity_Services_Reference/Invoice
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>
The Line
object I get from this SDK has no properties for SalesItemLineDetail or ItemRef on it.
Anyone have a working example of this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…