web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

creating payload with a zip file as for requests to Azur deployment

(0) ShareShare
ReportReport
Posted on by 5

I try to deploy the Azure function by using Rest API and zip-archive of solution.

It works properly in Postman. pastedimage1662097003579v1.png

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?

I have the same question (0)
  • Suggested answer
    Marco Mels Profile Picture
    on at
    RE: creating payload with a zip file as for requests to Azur deployment

    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.

    www.yammer.com/dynamicsnavdev

    www.dynamicsuser.net/.../14

    I will open this up to the community in case they have something to add.

    Thanks.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sumit Singh Profile Picture

Sumit Singh 2,707

#2
Sohail Ahmed Profile Picture

Sohail Ahmed 2,675 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 2,228 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans