Создание файла и запись содержимого в него в Dynamics Business Central (AL) - PullRequest
0 голосов
/ 09 января 2020

Я пытаюсь создать файл в azure хранилище с помощью Dynamics Business Central, а затем пытаюсь записать строку в файл. Я не могу создать файл. Может ли кто-нибудь помочь мне в этом отношении.

Мой пример кода

cha := 13;
    msVersion := '02-14-2014';
    MethodType := 'CreateFile';
    keyss := 'i0PNZ6Ykse7oSSfUzFeA36rQf5wybQWh5Jol0NRM4sal4s8B3ipkjvfzcsP8';
    //contenttype := 'This is sample text.';
    //contentLength := StrLen(contenttype);
    dateInRfc1123Format := CurrentDateTime;
    //canonicalizedHeaders := 'x-ms-date:' + FORMat(dateInRfc1123Format) + Format(cha) + 'x-ms-version:02-02-2019';
    requestMethod := 'PUT';
    urlPath := 'lables/' + 'tre11.csv';
    canonicalizedResource := '/bcstorage/labes/tre11.csv';
    canonicalizedHeaders := 'x-ms-content-length:1024' + Format(cha) + 'x-ms-date:' + FORMat(dateInRfc1123Format) + Format(cha) + 'x-ms-type:file' + Format(cha) + 'x-ms-version:' + msVersion;
    stringToSign := (requestMethod + Format(cha) + Format(cha) + Format(cha) + Format(cha) + Format(cha) + Format(cha) + Format(cha) + Format(cha) +
    Format(cha) + Format(cha) + Format(cha) + Format(cha) + canonicalizedHeaders + canonicalizedResource);


    authorizationHeader := 'SharedKey bc365storage:' + EncryptionManagement.GenerateBase64KeyedHashAsBase64String(stringToSign, keyss, 2);
    Message((authorizationHeader));
    request.SetRequestUri('https://bcstorage.file.core.windows.net/labes/tre11.csv');
    //request.GetHeaders(RequestHeader);
    request.Method := requestMethod;
    RequestHeader.Add('x-ms-date', FORMat(dateInRfc1123Format));
    RequestHeader.Add('x-ms-version', msVersion);
    RequestHeader.Add('Authorization', authorizationHeader);
    RequestHeader.Add('Accept-Charset', 'UTF-8');
    //RequestHeader.Add('Content-Type', 'text/xml;charset=utf-8');
    if MethodType = 'CreateFile' then begin
        RequestHeader.Add('x-ms-content-length', '1024');
        RequestHeader.Add('x-ms-type', 'file');
    end;

    client.Get('https://bcstorage.file.core.windows.net/labes/tre11.csv', hhtpres);
    hhtpres.Content.ReadAs(res);
    Message(res);
    test := client.Send(request, hhtpres);

Но я получаю неправильный ответ и не могу создать файл тоже .

...