curl -H "Content-Type: application/json" -X POST --data "@data.json"  http://localhost:3000/
            Asked
            
        
        
            Active
            
        
            Viewed 3,148 times
        
    -1
            
            
         
    
    
        brooksrelyt
        
- 3,925
- 5
- 31
- 54
 
    
    
        Athul
        
- 3
- 1
- 3
- 
                    Are you asking how to POST a file, or how to parse the result? – Thilo Oct 22 '15 at 06:28
- 
                    2http://stackoverflow.com/a/7173011/14955 – Thilo Oct 22 '15 at 06:29
- 
                    POST a file using curl to rest webservice – Athul Oct 22 '15 at 06:31
- 
                    In that link they are passing data as parameter .I want to pass a json file itself...like data.json... not the json content – Athul Oct 22 '15 at 06:33
- 
                    How about this one then: http://stackoverflow.com/a/7173621/14955 (but seems to be similar to what you are using now) – Thilo Oct 22 '15 at 06:36
- 
                    [How do you extract POST data in node.js?](http://stackoverflow.com/questions/4295782/how-do-you-extract-post-data-in-node-js) – Jonathan Lonowski Oct 22 '15 at 06:38
1 Answers
0
            curl can be used to send multiple types of content but the default of all being the application/x-www-form-urlencoded. If you need to send a file through the same , you need to put that in the header, and for putting a file you need to specify -d param for the same.
a sample use of the same can be as :
 $ curl -vX POST http://<servername>/<api>/v1/<jsonfilename.json> -d @<file.json> \
--header "Content-Type: application/json"
 
    
    
        Vishesh
        
- 167
- 2
- 11
- 
                    ok. If we passed like this there should be a POST method to handle this call. what will be the signature of that? – Athul Oct 22 '15 at 08:29