Skip to main content

Notifications

Announcements

No record found.

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

Add Journal VIA API

(1) ShareShare
ReportReport
Posted on by 94
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 94 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 75,723 Super User 2024 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

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,684 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,414 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans