Possibility to send a json object to a page type API
I know i can add a page for every json i receive but It would have been far more simple to accept this mode (and had the content into my blob)
ie. I would like to send to BC a file with a name and the content (a json)
My page layout looks like this
layout
{
area(Content)
{
repeater(GroupName)
{
field(id; Rec.SystemId)
{
Editable = false;
}
field(fileName; Rec."File Name") //text
{
}
field(fileContent; Rec."File Content") //blob
{
}
}
}
}
the body of my request:
{
"fileName": "pippo.json",
"fileContent": {
"drink": "soda",
"lines": [
{
"year": 2020,
"brand": "JEEP",
"model": "RENEGADE",
"serie": "120CV",
"kmCost": 0.4302,
"monthlyAmount": 2550
},
{
"year": 2020,
"brand": "JEEP",
"model": "COMPASS",
"serie": "115CV",
"kmCost": 0.45,
"monthlyAmount": 2650
}
]
}
}
this results in an error
{
"error": {
"code": "BadRequest",
"message": "Invalid Request Body CorrelationId: xxxxxxxxxxx"
}
}
instead if i change the format of the filecontent to a string
please note, that I had to:
Add " after "fileContent":
Add before every " the escape char \ (in the fileContent)
{
"fileName": "pippo.json",
"fileContent": "{\"drink\": \"soda\",\"lines\": [{\"year\": 2020,\"brand\": \"JEEP\",\"model\": \"RENEGADE\",\"serie\": 120CV\",\"kmCost\": 0.4302,\"monthlyAmount\": 2550},{\"year\": 2020,\"brand\": \"JEEP\",\"model\": \"COMPASS\",\"serie\": \"115CV\",\"kmCost\": 0.45,\"monthlyAmount\": 2650}]}"
}
this works but it's not very efficient (and also very hard to read).
Another example where this can be very usefull is for the PowerApp exchange of messages. (this way there will be only 1 page where you handle every "message" sent from the powerapp).
Thank you in advance,
Mattia
Business Central Team (administrator)
Thank you for this suggestion! Currently this is not on our roadmap. We are tracking this idea and if it gathers more votes and comments we will consider it in the future. Best regards, Business Central Team