Показать сообщение отдельно
Старый 10.03.2020, 23:27   #1  
alicedr is offline
alicedr
Участник
 
175 / 43 (2) +++
Регистрация: 06.07.2012
Адрес: Канада
D365 Multipart body length limit 16384 exceeded
D365 10.0.8

У клиента есть PDF файлы, прикрепленные к custtrans (накладные).
Задача: выгрузить конкретный PDF на внешний ресурс.
Внешний ресурс ожидает PUT запрос в формате multipart-form, одна из частей которого собственно файл.
Проблема в том, что при попытке отправить запрос, получаем сообщение "Multipart body length limit 16384 exceeded"
Как можно снять ограничение в D365FO или что нужно изменить в коде?

X++:
System.Net.ServicePointManager::set_SecurityProtocol(System.Net.SecurityProtocolType::Tls12);
            System.Net.WebRequest WebRequest = System.Net.WebRequest::Create(url);

            System.Net.WebHeaderCollection headerCollection = new System.Net.WebHeaderCollection();
            headerCollection.Add('UpdatedBy',SysUserInfo::find(curUserId()).Email);
            headerCollection.Add(System.Net.HttpRequestHeader::Authorization, "Bearer " + apiToken.access_token());

            webRequest.set_Method('PUT');
            webRequest.set_Headers(headerCollection);
            webRequest.set_ContentLength(strlen(content);
            webRequest.set_ContentType(contentType);

            stream = webRequest.GetRequestStream();
            streamWriter = new System.IO.StreamWriter(stream);
            streamWriter.Write(content);
            streamWriter.Close();

            webResponse = webRequest.GetResponse(); //have error here
content и contentType формируются так:
X++:
contentType = strfmt('multipart/form-data; boundary="%1"', boundary);
            content     = '--' + boundary
                    + #NewLine + 'Content-Disposition: form-data; name="jsonPart"'
                    + #NewLine + 'Content-Type: application/json'
                    + #NewLine + _json
                    + #NewLine
                    + '--' + boundary
                    + #NewLine + 'Content-Disposition: form-data; name="file"; filename="'+fileName+'"'
                    + #NewLine + 'Content-Type: application/octet-stream'
                    + #NewLine + fileStream.ToString()
                    + #NewLine
                    + '--' + boundary + '--'
                    + #NewLine;