node.js - How send file content in a form field on CURL? -
i use postman send post requests. use form fields , have field "data". in these field paste complete content of xml-file. work fine!
now want use curl send post request dynamic xml-content. looking simple way fill xml content in field "data" on curl command.
i try:
curl -x post -h "content-type: application/x-www-form-urlencoded" --data "data=@/my/file/path" http://localhost:3001/import/myservice
if check request in nodejs code there no content in request params filename.
my node code is:
router.post('/import/myservice', function(req, res) { let data = req.body.data; ... }
content of data "@/my/file/path" need like
data= '<?xml version="1.0" encoding="iso-8859-1"?> ...'
if put data in file should enter line below:
curl -x post -h "content-type: application/x-www-form-urlencoded" --data "@my.file.path" http://localhost:3001/import/myservice
take right here might help.
Comments
Post a Comment