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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

OData - Create a LedgerJournalHeader and Lines in one POST request

(2) ShareShare
ReportReport
Posted on by 26

For a POC, I am trying to create a general ledger Journal Header + Lines via the ODATA service.

I can do this successfully by making multiple calls:-

- POST the header - get back the ID of the created record (BatchNumber)

- POST each LedgerJournalLine item, this needs the batch number set as a foreign key which I have obtained from above.

So for a general ledger journal that has 4 items, thats a total of 5 http requests (1 for header + 4 lines)

This is not ideal.

i can see that I can query for headers and include their lines in a single GET request using the $expand odata syntax.

```
https://your-org.trial.operations.dynamics.com/data/LedgerJournalHeaders?$filter=dataAreaId eq %27demf%27&cross-company=true&$expand(LedgerJournalLines)

```

I tried POSTing the following JSON payload - its the same Header payload that posted successfully on its own, but I've tried to set it's `LedgerJournalLine` navigation property with an array of lines to be included:

```

{
"dataAreaId": "demf",
"JournalName": "GenJrn",
"Description": "Posted by poc",
"LedgerJournalLine": [
{
"dataAreaId": "demf",
"ReverseEntry": "No",
"ItemSalesTaxGroup": "FULL",
"CashDiscountDate": "1900-01-01T00:00:00Z",
"Text": "Test",
"OffsetAccountType": "Ledger",
"IsWithholdingCalculationEnabled": "No",
"ReverseDate": "1900-01-01T00:00:00Z",
"TransDate": "2022-12-16T13:38:15.8721698Z",
"DefaultDimensionDisplayValue": "",
"PaymentReference": "",
"Document": "",
"CashDiscountAmount": 0,
"ExchRate": 100,
"ChineseVoucherType": "",
"DebitAmount": 0,
"SalesTaxCode": "",
"DocumentDate": "1900-01-01T00:00:00Z",
"OffsetAccountDisplayValue": "",
"AccountDisplayValue": "618170-001--",
"CashDiscount": "",
"OffsetDefaultDimensionDisplayValue": "",
"SalesTaxGroup": "",
"AccountType": "Ledger",
"Invoice": "",
"DueDate": "1900-01-01T00:00:00Z",
"ReportingCurrencyExchRate": 0,
"PaymentMethod": "",
"PaymentId": "",
"PostingProfile": "",
"ExchRateSecond": 0,
"CreditAmount": 100000,
"OverrideSalesTax": "No",
"OffsetCompany": "demf",
"Quantity": 0,
"ItemWithholdingTaxGroupCode": "",
"TaxExemptNumber": "",
"ReportingCurrencyExchRateSecondary": 0,
"CurrencyCode": "EUR",
"Company": "demf",
"ChineseVoucher": "",
"DiscountPercentage": 0,
"OffsetText": ""
},
{
"dataAreaId": "demf",
"ReverseEntry": "No",
"ItemSalesTaxGroup": "FULL",
"CashDiscountDate": "1900-01-01T00:00:00Z",
"Text": "Test",
"OffsetAccountType": "Ledger",
"IsWithholdingCalculationEnabled": "No",
"ReverseDate": "1900-01-01T00:00:00Z",
"TransDate": "2022-12-16T13:38:15.8729043Z",
"DefaultDimensionDisplayValue": "",
"PaymentReference": "",
"Document": "",
"CashDiscountAmount": 0,
"ExchRate": 100,
"ChineseVoucherType": "",
"DebitAmount": -100000,
"SalesTaxCode": "",
"DocumentDate": "1900-01-01T00:00:00Z",
"OffsetAccountDisplayValue": "",
"AccountDisplayValue": "618170-001--",
"CashDiscount": "",
"OffsetDefaultDimensionDisplayValue": "",
"SalesTaxGroup": "",
"AccountType": "Ledger",
"Invoice": "",
"DueDate": "1900-01-01T00:00:00Z",
"ReportingCurrencyExchRate": 0,
"PaymentMethod": "",
"PaymentId": "",
"PostingProfile": "",
"ExchRateSecond": 0,
"CreditAmount": 0,
"OverrideSalesTax": "No",
"OffsetCompany": "demf",
"Quantity": 0,
"ItemWithholdingTaxGroupCode": "",
"TaxExemptNumber": "",
"ReportingCurrencyExchRateSecondary": 0,
"CurrencyCode": "EUR",
"Company": "demf",
"ChineseVoucher": "",
"DiscountPercentage": 0,
"OffsetText": ""
}
]
}

```

When I do this I get Bad Request error with this message:

```

"message":"Cannot apply PATCH to navigation property 'LedgerJournalLine' on entity type 'Microsoft.Dynamics.DataEntities.LedgerJournalHeader'.","type":"System.InvalidOperationException","stacktrace":" at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataEntityDeserializer.ReadODataBody[T](HttpRequestMessage request)"
}
}

```

I know there is a seperate Batch api but that looks even more complicated to use, so I wanted to pursue whether it was possible to create a journal header and its lines in a single HTTP request without using that.


I have the same question (3)
  • CU26080734-0 Profile Picture
    2 on at
    Did you got anything on this?
  • Suggested answer
    Anthony Blake Profile Picture
    3,156 Super User 2026 Season 1 on at
    I think that the $Batch functionality is the way to go on this one unfortunately, its not easy to get working using Postman, but it much easier using the C# OData Connected Service as the batch functionality is built in so you just set some parameters in your code.
     
     
    Another old article, but take a look here for the OData Connected Service: https://community.dynamics.com/blogs/post/?postid=f4207895-68a2-41d5-9312-c85b917a5a1e

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 689

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 478 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 258 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans