I try to deploy the Azure function by using Rest API and zip-archive of solution.
It works properly in Postman.
I've found advice on how to upload mp3 files https://arnitek.com/2019/02/10/al-post-binary-file-over-http/ and develop a solution for my task.
But when I try to create a payload for request by AL-code for Business Central (file have been uploaded to instr):
CR := 13; LF := 10; NewLine += '' + CR + LF; httpHeader.Clear(); TempBlob.CreateOutStream(PayloadOutStream); PayloadOutStream.WriteText('--boundary' + NewLine); PayloadOutStream.WriteText(StrSubstNo('Content-Disposition: form-data; name="file"; filename="%1"', filename) + NewLine); PayloadOutStream.WriteText('Content-Type: application/zip' + NewLine); PayloadOutStream.WriteText(NewLine); CopyStream(PayloadOutStream, InStr); PayloadOutStream.WriteText(NewLine); PayloadOutStream.WriteText('--boundary'); PayloadOutStream.WriteText(NewLine); TempBlob.CreateInStream(PayloadInStream); Content.WriteFrom(PayloadInStream); Content.GetHeaders(httpHeader); if httpHeader.Contains('Content-Type') then httpHeader.Remove('Content-Type'); httpHeader.Add('Content-Type', 'multipart/form-data;boundary=boundary'); httpRequest := CreateHttpRequestMessage(Content, 'Post', RequestURI); Client.Clear(); Client.DefaultRequestHeaders.Add('Authorization', StrSubstNo('Bearer %1', token)); if Client.Send(httpRequest, httpResponse) then begin httpResponse.Content().ReadAs(responseText); Message(responseText); end else Error(RequestErrorMsg);
I received an error in the response message from the deployment process like this:
{"Message":"An error has occurred.","ExceptionMessage":"Number of entries expected in End Of Central Directory does not correspond to number of entries in Central Directory.","ExceptionType":"System.IO.InvalidDataException","StackTrace":" at System.IO.Compression.ZipArchive.ReadCentralDirectory()\r\n at System.IO.Compression.ZipArchive.get_Entries()\r\n at Kudu.Core.Infrastructure.ZipArchiveExtensions.Extract(ZipArchive archive, String directoryName, ITracer tracer, Boolean doNotPreserveFileTime) in C:\\Kudu Files\\Private\\src\\master\\Kudu.Core\\Infrastructure\\ZipArchiveExtensions.cs:line 114\r\n at Kudu.Services.Deployment.PushDeploymentController.<>c__DisplayClass21_0.<LocalZipFetch>b__1() in C:\\Kudu Files\\Private\\src\\master\\Kudu.Services\\Deployment\\PushDeploymentController.cs:line 746\r\n at System.Threading.Tasks.Task.InnerInvoke()\r\n at System.Threading.Tasks.Task.Execute()......
I believe, something is wrong when I build the payload. Could you give me advice on how I have to build the body of the request for my case?
Hello,
We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist. If you need assistance with debugging or coding I would recommend discussing this on one of our communities.
I will open this up to the community in case they have something to add.
Thanks.
Sumit Singh
2,707
Sohail Ahmed
2,675
Super User 2025 Season 2
YUN ZHU
2,228
Super User 2025 Season 2