Hi fellow developers,
I am looking for a way to receive and process JSON data posted into Business Central via external API.
After some research I found the easiest way to achieve this is to write a CodeUnit with parameter to get the Json payload. Below is my Codeunit:
codeunit 50220 "Process Json Data"
{
procedure ProcessJson(orderReference: Text; orderDetails: BigText): Text
begin
//code to process JSON
end;
}
and the json content I want to process:
{
"orderReference": "PO123456789",
"orderDetails": [
{
"manufactureDate": "2022-04-09",
"itemCode": "item1",
"quantity": 20,
},
{
"manufactureDate": "2022-04-09",
"itemCode": "item2",
"quantity": 20,
}
]
}
So far, I tried many data types for orderDetails(JsonObject, Text, BigText...), but I still could not get the "orderDetails" into the CodeUnit parameter and I kept getting 400 or 404 errors.
Can someone please help me with receiving the above JSON body with codeunit parameter? If anyone has better solutions, please let me know too. Thanks in advance!