axa-group / Parsr

Transforms PDF, Documents and Images into Enriched Structured Data
Apache License 2.0
5.81k stars 310 forks source link

API Calling Using Curl Command #374

Closed sjaintdl closed 4 years ago

sjaintdl commented 4 years ago

Hi @jvalls-axa ,

When i am trying to calling the API through CMD.exe using Curl command but it is giving error that you can see below -

<!DOCTYPE html>

Error
MulterError: Unexpected field
   at wrappedFileFilter (D:\Jain University\Final Year\Parsr\Parsr-0.11.1\Parsr-0.11.1\api\server\node_modules\multer\index.js:40:19)
   at Busboy.<anonymous> (D:\Jain University\Final Year\Parsr\Parsr-0.11.1\Parsr-0.11.1\api\server\node_modules\multer\lib\make-middleware.js:114:7)
   at Busboy.emit (events.js:311:20)
   at Busboy.emit (D:\Jain University\Final Year\Parsr\Parsr-0.11.1\Parsr-0.11.1\api\server\node_modules\busboy\lib\main.js:38:33)
   at PartStream.<anonymous> (D:\Jain University\Final Year\Parsr\Parsr-0.11.1\Parsr-0.11.1\api\server\node_modules\busboy\lib\types\multipart.js:213:13)
   at PartStream.emit (events.js:311:20)
   at HeaderParser.<anonymous> (D:\Jain University\Final Year\Parsr\Parsr-0.11.1\Parsr-0.11.1\api\server\node_modules\dicer\lib\Dicer.js:51:16)
   at HeaderParser.emit (events.js:311:20)
   at HeaderParser._finish (D:\Jain University\Final Year\Parsr\Parsr-0.11.1\Parsr-0.11.1\api\server\node_modules\dicer\lib\HeaderParser.js:68:8)
   at SBMH.<anonymous> (D:\Jain University\Final Year\Parsr\Parsr-0.11.1\Parsr-0.11.1\api\server\node_modules\dicer\lib\HeaderParser.js:40:12)
jvalls-axa commented 4 years ago

Hi @sjaintdl

Could you please paste curl command you're using ??

sjaintdl commented 4 years ago

Hi @jvalls-axa ,

I 'm using curl command below -

curl -X POST http://localhost:3001/api/v1/document -H 'Content-Type:multipart/form-data' -F 'file=@CSE.pdf;type=application/pdf' -F 'config=@"D:\Jain University\Final Year\Parsr\Parsr-0.11.2\Parsr-0.11.2\server\defaultConfig.json";type=application/json'

jvalls-axa commented 4 years ago

The issue is that CURL in Windows needs to use double quotes instead of singe quote.

Single quote - Failing Curl_KO

Double quotes - Working Curl_OK

Try this

curl -X POST http://localhost:3001/api/v1/document -H "Content-Type:multipart/form-data" -F "file=@CSE.pdf;type=application/pdf" -F "config=@D:\Jain University\Final Year\Parsr\Parsr-0.11.2\Parsr-0.11.2\server\defaultConfig.json;type=application/json"

We will improve our documentation to solve that issue.

sjaintdl commented 4 years ago

Thanks @jvalls-axa , To help me on this.

sjaintdl commented 4 years ago

hi @jvalls-axa , but when i using command below to download CSV file - curl -X GET http://localhost:3001/api/v1/csv/559842b883f4b161fead7ca1b29e7b?download=1

then it is not downloading ZIP file, it asking for -

Warning: Binary output can mess up your terminal. Use "--output -" to tell Warning: curl to output it to your terminal anyway, or consider "--output Warning: " to save to a file.

Data.zip

And for other download API is not downloading, that only displaying the data on the terminal.

and when i am giving path but is saving as different file that you can see in attachments -

jvalls-axa commented 4 years ago

Hi

Just one Google search to find something like this