Эти данные отправлены почтальоном и работают:
Это запрос почтальона, который проходит со статусом 200:
POST /api/upload HTTP/1.1
Host: api.test.contoso.se
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Authorization: Basic 123
User-Agent: PostmanRuntime/7.13.0
Accept: */*
Cache-Control: no-cache
Postman-Token: 089af753-fa12-46c4-326f-dfc39c36faab,c5977145-ece3-4b53-93ff-057788eb0dcf
Host: api.test.contoso.se
accept-encoding: gzip, deflate
content-length: 18354
Connection: keep-alive
cache-control: no-cache
Content-Disposition: form-data; name="Lang"
SV
------WebKitFormBoundary7MA4YWxkTrZu0gW--
Content-Disposition: form-data; name="File"; filename="/C:/Users/file.docx
------WebKitFormBoundary7MA4YWxkTrZu0gW--
Content-Disposition: form-data; name="Login"
ABC
Это мой запрос от NodeJ через Axios:
const form_data = new FormData();
form_data.append("File", fs.createReadStream(pathToFile));
form_data.append('Login', alias.toUpperCase());
console.log(form_data); // se output down
const request_config = {
headers: {
"Authorization": "Basic 123",
"Content-Type": `multipart/form-data; boundary=${form_data._boundary}`
},
data: form_data
};
console.log (form_data):
FormData {
_overheadLength: 540,
_valueLength: 13,
_valuesToMeasure:
[ ReadStream {
_readableState: [ReadableState],
readable: true,
_events: [Object],
_eventsCount: 3,
_maxListeners: undefined,
path:
'/Users/qq/test.docx',
fd: null,
flags: 'r',
mode: 438,
start: undefined,
end: Infinity,
autoClose: true,
pos: undefined,
bytesRead: 0,
closed: false,
emit: [Function] } ],
writable: false,
readable: true,
dataSize: 0,
maxDataSize: 2097152,
pauseStreams: true,
_released: false,
_streams:
[ '----------------------------610001147909085905792533\r\nContent-Disposition: form-data; name="File"; filename="test.docx"\r\nContent-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document\r\n\r\n',
DelayedStream {
source: [ReadStream],
dataSize: 0,
maxDataSize: Infinity,
pauseStream: true,
_maxDataSizeExceeded: false,
_released: false,
_bufferedEvents: [Array],
_events: [Object],
_eventsCount: 1 },
[Function: bound ],
'----------------------------610001147909085905792533\r\nContent-Disposition: form-data; name="Login"\r\n\r\n',
'abc',
[Function: bound ] ],
_currentStream: null,
_insideLoop: false,
_pendingNext: false,
_boundary: '--------------------------610001147909085905792533
Ошибка, которую я получаю от сервера ASP: Line length limit 100 exceeded
Чего мне не хватает в моем запросе?