web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

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

Add Journal VIA API

(1) ShareShare
ReportReport
Posted on by 152
I am trying to figure out how to create a Journal Entry by using the API.
Is the sequence I am explaining correct?
 
1. I use the following to GET the company.
 
2. Then I use the company to GET the journal batch.
 
3. Then I use journal batch to GET the journal entry I want to add a new line to.
 
4. Then I POST to add a new journal line the following data as a json object.
            Dim postdataje As New JObject
            postdataje.Add(/lineNumber/, /3000/)
            postdataje.Add(/accountType/, /G_x002F_L_x0020_Account/)
            postdataje.Add(/accountNumber/, /12130/)
            postdataje.Add(/postingDate/, /2024-05-28/)
            postdataje.Add(/documentNumber/, /G00003/)
            postdataje.Add(/externalDocumentNumber/, //)
            postdataje.Add(/amount/, /500/)
            postdataje.Add(/balanceAccountType/, /G_x002F_L_x0020_Account/)
 
The actual post request looks like:
           httpWebRequest.ContentType = /application/json/
            httpWebRequest.Method = /POST/
            httpWebRequest.Headers.Add(/Authorization/, /Bearer / & token)
            httpWebRequest.KeepAlive = True
            httpWebRequest.Accept = /application/json/
 
I end up getting an error which I am trying to figure out:
 
(400) Bad Request.
 
Does all this look correct?
 
Thanks Keith
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    95,307 Super User 2025 Season 2 on at
    Add Journal VIA API
    Hi, looks like the If-Match is missing, hope the following can give you some hints.
    httpWebRequest.Headers.Add("If-Match", "*");
     
    Thanks.
    ZHU
  • DS-15051354-0 Profile Picture
    152 on at
    Add Journal VIA API
    I got it working. ContentType = application.json was invalid on my request. I reentered httpWebRequest.ContentType = /application/json/ and it worked.
     
    It seems  I don't need to enter If-Match I see that it is required but works without it.
     
    Thanks for your help

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,377

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,696 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,512 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans