Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

Can't create PurchaseInvoices through API

(0) ShareShare
ReportReport
Posted on by 5

Hello,

I have used below api and body and while sending post request getting error as mentioned below

API

api.businesscentral.dynamics.com/.../purchaseInvoices

Body

{
    "invoiceDate""2020-04-10",
    "postingDate""2020-04-10",
    "dueDate""2020-04-30",
    "vendorInvoiceNumber""107210",
    "vendorId""9e3833b3-b1fd-ea11-bc7d-00155df3a615",
    "vendorNumber""20000",
    "payToVendorId""9e3833b3-b1fd-ea11-bc7d-00155df3a615",
    "payToVendorNumber""20000",
    "shipToName""",
    "shipToContact""",
    "buyFromAddressLine1""100 Day Drive",
    "buyFromAddressLine2""",
    "buyFromCity""Chicago",
    "buyFromCountry""US",
    "buyFromState""IL",
    "buyFromPostCode""61236",
    "shipToAddressLine1""7122 South Ashford Street",
    "shipToAddressLine2""Westminster",
    "shipToCity""Atlanta",
    "shipToCountry""US",
    "shipToState""",
    "shipToPostCode""31772",
    "shortcutDimension1Code""0002",
    "shortcutDimension2Code""ADM",
    "currencyCode""USD",
    "pricesIncludeTax"false,
    "discountAmount"0,
    "discountAppliedBeforeTax"true,
    "totalAmountIncludingTax"1911.82
}
Error
{
    "error": {
        "code""Internal_RecordNotFound",
        "message""The Purchase Header does not exist. Identification fields and values: Document Type='Invoice',No.=''  CorrelationId:  40ff1593-4201-4a7d-925b-c28d694f282a."
    }
}
Can anyone please help on it?
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    Khushbu Rajvi. 8,840 Super User 2025 Season 1 on at
  • mjjoachim Profile Picture
    mjjoachim 3 on at
    Can't create PurchaseInvoices through API
    I get this error if I specify a posting date.

    [Update]
    I have figured out why I get this error if I specify a value for the Posting Date field. In my case, I believe the call is failing before the Purchase Header is assigned a No. or created. The failure seems to be happening in an event subscriber for the OnAfterValidateEvent event for the Posting Date field in the IRS Forms app that calls Modify() on the Purchase Header record before it has been inserted.
  • YanivBokobza Profile Picture
    YanivBokobza 7 on at
    RE: Can't create PurchaseInvoices through API

    Hi, I'm getting the same exact error while the No. Series is defined just right for purchase invoice.

    Did you managed to fix this?

  • RE: Can't create PurchaseInvoices through API

    Have used version 2.0 and request seems like as below and used postman to test it

    POST /v2.0/{guid}/InstallTest/api/v2.0/companies({compantid})/purchaseInvoices HTTP/1.1

    Host: api.businesscentral.dynamics.com

    Authorization: Basic username+password

    Content-Type: application/json

    Content-Length: 1049

    {

       "number": "107676",

       "invoiceDate": "2020-04-10",

       "postingDate": "2020-04-10",

       "dueDate": "2020-04-30",

       "vendorInvoiceNumber": "107210",

       "vendorId": "9e3833b3-b1fd-ea11-bc7d-00155df3a615",

       "vendorNumber": "20000",

       "payToVendorId": "9e3833b3-b1fd-ea11-bc7d-00155df3a615",

       "payToVendorNumber": "20000",

       "shipToName": "",

       "shipToContact": "",

       "buyFromAddressLine1": "100 Day Drive",

       "buyFromAddressLine2": "",

       "buyFromCity": "Chicago",

       "buyFromCountry": "US",

       "buyFromState": "IL",

       "buyFromPostCode": "61236",

       "shipToAddressLine1": "7122 South Ashford Street",

       "shipToAddressLine2": "Westminster",

       "shipToCity": "Atlanta",

       "shipToCountry": "US",

       "shipToState": "",

       "shipToPostCode": "31772",

       "shortcutDimension1Code": "0002",

       "shortcutDimension2Code": "ADM",

       "currencyCode": "USD",

       "pricesIncludeTax": false,

       "discountAmount": 0,

       "discountAppliedBeforeTax": true,

       "totalAmountIncludingTax": 1911.82

    }

  • Suggested answer
    Vaishnavi J Profile Picture
    Vaishnavi J 3,056 on at
    RE: Can't create PurchaseInvoices through API

    Hi,

    Have you used standard API form Microsoft which version you have used v1.0 or v2.0?

    If my answer was helpful to you, please verify it so that other users know it worked. Thank you very much

  • RE: Can't create PurchaseInvoices through API

    Hi,

    i have tried that but still getting same error

    {

       "error": {

           "code": "Internal_RecordNotFound",

           "message": "The Purchase Header does not exist. Identification fields and values: Document Type='Invoice',No.='107676'  CorrelationId:  65bcc35e-474f-4bd6-9a27-dcad9e9d0025."

       }

    }

  • Suggested answer
    Vaishnavi J Profile Picture
    Vaishnavi J 3,056 on at
    RE: Can't create PurchaseInvoices through API

    Hi,

    Please check if the Purchase Invoice No series has Default check mark in the No series setup.

    If my answer was helpful to you, please verify it so that other users know it worked. Thank you very much

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,375 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans