I’m implementing a journal import process for cross-company transactions in D365 10.0.40 financial accounting. The integration posts intercompany journals between legal entities, but the API consistently returns “Invalid account - account does not exist in the specified legal entity.”
The accounts definitely exist in both legal entities - I can manually post the same journal entries through the UI without issues. The problem only occurs with API imports. I’ve verified the account numbers are correct and active in both the source and destination legal entities.
Sample API call:
POST /api/data/v9.0/generaljournals
{
"journalName": "INTERCO",
"lines": [{
"accountNum": "110100",
"debit": 5000,
"offsetAccount": "210100",
"dataAreaId": "USMF"
}]
}
I suspect this is related to the legal entity context or DataAreaId handling in cross-company scenarios. The error occurs specifically when posting to the offset legal entity. How should I properly set the legal entity context and configure cross-company permissions for API-based journal imports?
Also check your intercompany posting setup. Cross-company journal imports require the intercompany relationships to be properly configured between the legal entities. Go to General Ledger > Setup > Intercompany > Intercompany accounting and verify that both legal entities are set up as trading partners. The API enforces these relationships even though the UI might allow you to bypass them with appropriate security permissions. Without proper intercompany setup, the API will reject the journal lines.
You also need to verify that your API service principal has cross-company permissions. The account validation error might actually be a permissions issue disguised as an account error. Check that your service principal has been granted the “Access all legal entities” permission in the security configuration. Without this, the API can only validate accounts in the default legal entity context, which would explain why some accounts appear invalid even though they exist.
I’ve dealt with this exact scenario. The key is understanding that cross-company journals in D365 are actually two separate journal entries linked by intercompany references. When you post through the UI, D365 automatically creates the corresponding entry in the offset legal entity. The API doesn’t do this automatically - you need to explicitly create both journal entries and link them with intercompany reference fields. This is why your account validation fails - you’re trying to post an offset to a different legal entity in a single journal entry, which the API doesn’t support.
Thanks for the insights. I checked the intercompany setup and the trading partner relationships are configured correctly. However, I’m still confused about the DataAreaId usage. Should I set DataAreaId on the journal header to the source legal entity and then set a different DataAreaId on individual lines for the offset legal entity? Or do I need to create separate journal headers for each legal entity involved?