I need to make a post using nodejs. I will send a text and a json file content to a url. Using insomia I can send normally (print below), but not in the code integration. Does anyone have an example?
SEND OK
ERROR
Related
I want to do following:
User creates a request using a form-data
The form-data contains and multipart files(upload them via multer)
I want to save logs about files and params. Can you help how can i do this, only if files provided
Thanks
My pdf file is being sent to my server as binary data with Postman as seen in the picture attached.
The content of the file is being parsed on my ExpressJS server with req.on((chunk) => ...) etc.
Everything is fine, except the fact that I try to obtain the original filename(highlighted in red - valid-compressed-compressed.pdf) on the server, but I can't find the value anywhere in the request object.
Any suggestions, please?
Short answer: you cant.
If you look closely at the headers being sent with the request, there are no headers containing the filename. Therefore there are no headers you can access in express to retrieve that information. The only headers you send are Content-Type and Content-Length that gives some information about what you're sending. Other than that there's just the binary request body.
If you want to post a file and the filename you need to look into multipart/form-data (Multer).
I trying to send CSV file via post request from postman but I am getting error.Please help how to send csv file from postman.
Because you upload file, you should add header Content-Type: multipart/form-data to request or update the latest postman (which automatically add header for form-data based on data type)
For example
I am using the example given here: https://github.com/expressjs/multer. However instead of using the form in the example, I am using Postman to POST some data, however I am getting an empty body. I have set Postman to use form-data. Any ideas what the problem could be?
Thanks
I am working on angular (frontend) and node ( backend). I want to send an email using sendgrid , With excel file as attachment. I followed the app as reference demo app .Instead of downloading the excel, I want the same file to be sent as email attachment.
Note : In the backend I use nodejs, I am not sure how to pass the file with API to node.js, I can send email in nodejs code.
Can someone help me on this?
You can make an http post request in the node api back-end and pass the file. Do post using headers as Multipart form request.
Multipart form request helps you to make the node js api pass the excel sheet generated on the front end.
In your email service add the http service call to the backend. And make the service pass the file in it
Check this link out for more details
https://blog.jscrambler.com/implementing-file-upload-using-node-and-angular/