I have the following problem: We have implemented a page (incl. table) of type "API" in our Business Central 365 environment (SaaS), which should receive posting information from an external financial accounting. This data is then further processed in a separate process. It is now the case that posting texts (freely fillable by the clerk) are also part of this posting information. Since we are in the German language area, it can happen that German umlauts are used in these posting texts. If we now want to use a simple Powershell script to transfer this data from the source system to the target system via an API call, the umlauts are not resolved correctly. Thus a "ü" becomes a "\u00fc" in the target column. We use (for test purposes) the following Powershell script:
$Headers = @{
"Content-type" = "application/json; charset=utf-8"
"Content-Transfer-Encoding" = "binary"
"Authorization" = "Bearer " + $BearerToken
"Company" = "xxxxxxxx-xxxx-xxx-xxxx-xxxxxxxxxxxx"
}
$body = @{
"requests" = @(
@{
"method" = "POST"
"id" = "REQ1"
"url" = "companies(xxxxxxxx-xxxx-xxx-xxxx-xxxxxxxxxxxx)/transactions"
"headers" = @{
"Content-Type" = "application/json; charset=utf-8"
"Content-Transfer-Encoding" = "binary"
}
"body" = @{
"ABRECHNUNGNR" = "6661"
"BUCHUNGSTEXT" = "Büromöbel"
}
}
)
}
$bodyText = ($body | ConvertTo-Json -Depth 100)
$url = 'https://api.businesscentral.dynamics.com/v2.0/Environment/api/publisher/transaction/v1.0/$batch'
$response = Invoke-RestMethod -Method Post -Uri $url -Headers $Headers -Body $bodyText
After the transfer to Business Central 365 (SaaS) we get the following value for "BUCHUNGSTEXT" in the target table:
We would have expected the transferred "BUCHUNGSTEXT" to appear in Business Central as we specified it.
We are urgently looking for a possible solution. Thank you very much for your support.
UPDATE 2023-08-26
We have solved the problem: We found out that it makes a difference in which notation you use for the data attributes. In the API page, the attribute name is "buchungstext". But we have specified the attribute as "BUCHUNGSTEXT" in our request. However, I cannot provide a reason for this. After we specified the attributes in the batch request in the correct notation, the encoding problem disappeared.
Thanks all for your help!