NAV 2018 - how to insert record in Table "Gen. Journal Line" with use of JSON over "API Page" ??

dalmatinkodalmatinko Member Posts: 11
Hi to all modern and "old fashion" NAV guys,

Hope so someone can help me with example how to insert record from external application with usage of API Page in the background.
For testing purpose I've used "Postman" to connect Cronus NAV 2018, and to send instructions to the NAV.
I was able to read records (GET) from the "Gen. Jorunal Line", but have issue when tryy to (POST) insert new record with use of "Journal Entity" pages.

This is connection/execution string (works fine when read records from NAV):
'GET http://something:7048/DynamicsNAV110/api/beta/journals(bc05cb5f-fc37-496d-a856-3362c035d687)?$expand=journalLines'
where 'bc05cb5f-fc37-496d-a856-3362c035d687' presents the GUID of "Gen. Journal Batch" record.

This is connection/execution string and JSON format data when try to insert record into NAV:
'POST http://something:7048/DynamicsNAV110/api/beta/journals(bc05cb5f-fc37-496d-a856-3362c035d687)?$expand=journalLines'

{
"journalLines":
[
{
"lineNumber": 30000,
"accountId": "59c5cd49-5581-4f03-bfb2-d7f387f6ac5a",
"accountNumber": "1220",
"postingDate": "2019-07-16",
"documentNumber": "G00002",
"externalDocumentNumber": "",
"amount": 500,
"description": "Increases during the Year",
"comment": "",
"dimensions": [
{
"code": "AREA",
"displayName": "Area",
"valueCode": "50",
"valueDisplayName": "Europe South"
},
{
"code": "CUSTOMERGROUP",
"displayName": "Customer Group",
"valueCode": "SMALL",
"valueDisplayName": "Small Business"
},
{
"code": "DEPARTMENT",
"displayName": "Department",
"valueCode": "PROD",
"valueDisplayName": "Production"
}
]

}
]
}


and the error message received is:

{
"error": {
"code": "BadRequest_MethodNotAllowed",
"message": "'POST' requests for 'journals' of EdmType 'Entity' are not allowed within Microsoft Dynamics NAV OData web services."
}
}


I will appreciate if someone have experince with this, or any helping suggestion.

Thanks in advance !

Sign In or Register to comment.