i am trying to send an emtpy binary form-data request to an endpoint - with NODEJS. The field is required.
data.append('picture1',fs.createReadStream('./example-images/image-1.jpg'));
data.append('picture2', '');
data.append('picture3', fs.createReadStream('./example-images/image-3.jpg'));
async function makeRequest(filename,data) {
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'URL ENDPOINT',
headers: {
'Host': 'myhost.dot.net',
...data.getHeaders()
},
data : data,
responseType: "stream"
};
try {
const response = await axios.request(config);
const pdfContents = response.data;
}}
The request with Firefox works and looks.
` -----------------------------1273980944350463539931767001 Content-Disposition: form-data; name="name"
Form1 -----------------------------1273980944350463539931767001 Content-Disposition: form-data; name="picture1"; filename="image-1.jpg" Content-Type: image/jpeg
ÿØÿá....... -----------------------------1273980944350463539931767001 Content-Disposition: form-data; name="picture2"; filename="" Content-Type: application/octet-stream
-----------------------------1273980944350463539931767001 Content-Disposition: form-data; name="picture3"; filename="image-3.jpg" Content-Type: image/jpeg
ÿØÿá
-----------------------------1273980944350463539931767001-- `
Send Request with 3 pictures works, Send request with 2 pictures dont work.
any help who to send a empty binary form-data field?
Thx