I am able to POST
and invoice EntityType
to the Web API.
After creating the invoice
I get the guid
and I want to create invoice line items, which I believe are of invoicedetail EntityType
.
I cannot POST
a new invoicedetail
. Every attempt I make with a range of different properties I receive either an Error 500 - An unexpected error occurred.
or Error 500 - The parent id is missing.
An example of a JSON string I'm trying to POST
. (invoicedetailid
is the GUID
of the previous invoice I create)
{
"productdescription": "Test Line Item",
"invoicedetailid": "00000000-0000-0000-0000-0000000000000",
"priceperunit": 10,
"tax": 0,
"quantity": 1,
"baseamount": 10
}
The documentation is vague and I'm wanting to know, what are the minimum required fields for invoicedetail
and how can I POST
a new invoice EntityType
?
The field storing to lookup from invoicedetail
to invoice
is called invoiceid
(not invoicedetailid
, which is the id of the invoicedetail
itself). Additionally, you need to use the @odata.bind-annotation:
To associate new entities to existing entities when they are created you must set the value of single-valued navigation properties using the @odata.bind annotation.
The body of your POST request would thus look as follows:
{
"productdescription": "Test Line Item",
"invoiceid@odata.bind": "/invoices(guid-of-invoice-here)",
"priceperunit": 10,
"tax": 0,
"quantity": 1,
"baseamount": 10
}