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

Add Journal VIA API

(1) ShareShare
ReportReport
Posted on by 106
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
  • DS-15051354-0 Profile Picture
    DS-15051354-0 106 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
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 78,034 Super User 2025 Season 1 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

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

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,436 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans