Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

journalLines API throwing error

Posted on by 5

I am trying to POST the journalLines for an existing Journal but keep getting the error that the body of the request is bad. 

{"error":{"code":"BadRequest","message":"Invalid Request Body  CorrelationId:  19a40eab-63ef-48f9-83ee-fbed9cc7557d."}}

The documentation is confusing in that it is showing the ID of the journalLine to be part of the POST.  My experience using these API requests are that when you POST to Create an entry, the ID number is returned upon a successful POST.  Here is the documentation:

 

POST https://{businesscentralPrefix}/api/v2.0/companies({id})/journals({id})/journalLines

Content-type: application/json

 

{

    "id": "0a077d18-45e3-ea11-bb43-000d3a2feca1",                           This is the entry I don’t understand.  How can you know the Journal Line GUID before it is created?

    "journalId": "dd1b6a90-44e3-ea11-bb43-000d3a2feca1",          I populated this field (journalId) with the Journal GUID that was returned from creating the header.

    "journalDisplayName": "DEFAULT",

    "lineNumber": 10000,

    "accountType": "G/L Account",

    "accountId": "00000000-0000-0000-0000-000000000000",

    "accountNumber": "",

    "postingDate": "2018-12-31",

    "documentNumber": "",

    "externalDocumentNumber": "",

    "amount": 0,

    "description": "",

    "comment": "",

    "lastModifiedDateTime": "0001-01-01T00:00:00Z"

}

 

Any assistance or an example would be greatly appreciated.

Categories:
  • Suggested answer
    Marco Mels Profile Picture
    Marco Mels on at
    RE: journalLines API throwing error

    Hello,

    Feel free to raise the issue to Microsoft via your partner or CSP if you cannot get passed the error. Via Get you can get the ID of the journal. 

    Thank you.

  • t3chlady Profile Picture
    t3chlady 5 on at
    RE: journalLines API throwing error

    I did pass all of the fields you mention but still am getting the error.

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,025 Moderator on at
    RE: journalLines API throwing error

    Hi,

    You have pass below fields from Gen Line.

    Like : Template name, Batch Name, Line No., Account No. Posting Date, Amount, Bal. Acc. Type and Name. etc. Not the ID or other system created field.

  • t3chlady Profile Picture
    t3chlady 5 on at
    RE: journalLines API throwing error

    I get the same error without an id

  • Suggested answer
    Nitin Verma Profile Picture
    Nitin Verma 21,025 Moderator on at
    RE: journalLines API throwing error

    Hi,

    In the request body you only need to provide Gen Lines. data, not any ID.

    Thanks.

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,558 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,645 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans