Search code examples
c#intuit-partner-platformquickbooks-online

Creating product/Service in Quickbooks Online in an Invoice line item


I'm trying to create the service/product type in the invoice line item. It returns an error saying bad request, is my ItemRef phrased correctly. My service/product is created in qbo already, its called Subscription Fee, it's the 3rd in the dropdown list.

line.AnyIntuitObject = new Intuit.Ipp.Data.SalesItemLineDetail()
                            {
                                ItemRef = new Intuit.Ipp.Data.ReferenceType()
                                {
                                    Value = "3",
                                    type = "Item",
                                    name = "Subscription Fee"
                                },
                                ItemElementName = Intuit.Ipp.Data.ItemChoiceType.UnitPrice,
                                AnyIntuitObject = (decimal)item.Rate, // Line item rate
                                Qty = (decimal)item.Quantity,
                                QtySpecified = true,
                                ServiceDate = DateTime.Now.Date,
                                ServiceDateSpecified = true,
                                TaxCodeRef = new Intuit.Ipp.Data.ReferenceType()
                                {
                                    Value = taxCode0ZR.Id,
                                    type = Enum.GetName(typeof(Intuit.Ipp.Data.objectNameEnumType), Intuit.Ipp.Data.objectNameEnumType.TaxRate),
                                    name = taxCode0ZR.Name
                                },
                            };

What am i creating wrongly please help.


Solution

  • You cannot create an Item within an invoice or rather any entity within an entity. QBO v3 does not supports creating entities on the fly. You first need to do a create Item. Get the Id of that Item and refer it in your Invoice.

    Also, enable request/response log to get the details of the errors in log files- https://developer.intuit.com/docs/0025_quickbooksapi/0055_devkits/0150_ipp_.net_devkit_3.0/0002_configuration/override_configuration