I am trying to create Purchase Invoice and Lines together with single call. Is this possible? Can we use "Expand" functionality for this to create Invoice and lines together?
To answer some of my own question: I found a syntax that works:
docs.microsoft.com/.../dynamics_create_purchaseinvoiceline
POST businesscentralPrefix/companies({id})/purchaseInvoices({id})/purchaseInvoiceLines
But in Flow we can only pick from the standard list:
Or maybe somehow in Flow we can also use the same syntax? I a'm new to Flow. So basically - any ideas how to do this through Flow?
Lars
How to do it one line at the time, without the header? Here, I already have a Purchase Invoice, but only want to add a line. With this:
POST {{BaseURL}}/companies(177114a9-621d-ea11-bb2d-000d3a257ac8)/purchaseInvoiceLines
{
"accountId": "74eecaeb-621d-ea11-bb2d-000d3a257ac8",
"documentId": "5daf9442-d748-ea11-a812-000d3a722b1a"
}
I get this error:
Application_DialogException The value for documentId cannot be modified.
If I leave documentId empty I get an error that it must be specified... Any ideas to how to just insert a purchase line?
To create no need to use expand, Expand is used to retrieve . What matters is your JSON body must specify the line as well , below sample JSON to create header and line in single call.
{ "vendorInvoiceNumber":"", "invoiceDate":"2018-12-25", "dueDate":"2018-12-25", "vendorNumber":"10000", "purchaseInvoiceLines" : [ { "sequence":10000, "lineType":"Item", "itemId": "715f88b5-c1df-e911-bb22-000d3ab0ebc8", "description":"12 GG INTERNATIONAL", "directUnitCost":20000, "quantity":10, "unitOfMeasure": { "code": "PCS", "displayName": "Piece", "symbol": null, "unitConversion": null } }, { "sequence":20000, "lineType":"Item", "itemId": "715f88b5-c1df-e911-bb22-000d3ab0ebc8", "description":"ES TEH MANIS", "directUnitCost":5000, "quantity":5, "unitOfMeasure": { "code": "PCS", "displayName": "Piece", "symbol": null, "unitConversion": null } } ] }
You can also check my blog post :
https://madearipermadi.com/2019/12/19/postman-collection-to-explore-business-central-api/
it has sample in Postman collection
Yes C# but I am trying to test this from Postman first.
I am trying to create an Invoice with POST Method combining $expand parameter like this to create the Purchase Invoice and Lines together:
POST https://{businesscentralPrefix}/api/v1.0/companies({id})/purchaseInvoices?$expand=purchaseInvoiceLines
Can this be used to create Purchase Invoice and Lines together? In my case, its not accepting the Purchase Lines. Any Idea why its not accepting the PurchaseInvoicelines?
whats your code, which calls the webservice? c#?
sorry should have been mentioned this earlier. I am trying to create Purchase Invoices/InvoiceLines via Web Service.
via web service or al?
Sohail Ahmed
944
YUN ZHU
848
Super User 2025 Season 1
Mansi Soni
602