-
Notifications
You must be signed in to change notification settings - Fork 296
Closed
Description
Details
Hi guys, i was wondering if anyone could help me out. I'm currently working om some sort of tool that is using API calls, and i need to send a ZIP file as form params to the server. In curl it is using the tags -F "file=@filename.zip"
but i was wondering how i can do this with nodejs. I currently have the following code but it gives me a 400 bad request:
let form = new FormData();
form.append('file', fs.readFileSync(`./apigee/proxies/${file}`));
let response = await fetch(`${to}/v1/organizations/${torg}/apis?action=import&name=${file.slice(0,-4)}`, {
method: 'post',
body: form,
headers: {'Authorization': `Bearer ${ta}`, 'Content-Type': 'multipart/form-data'}
});
Node.js version
Not applicable.
Example code
No response
Operating system
Windows
Scope
code
Module and version
Not applicable.
Metadata
Metadata
Assignees
Labels
No labels