curlpostcouchdbcouchdb-mango

CouchDB POST request using curl hanging


I have CouchDB v2.2.0 installed on a Linux server. I have 5 databases create:

I can successfully run a Mango query from Fauxton using the contents of the json file listed below.

I can successfully connect to the model_attriubute_groups database from another Linux server using a curl GET command:

curl -v http://my.server.com:5984/model_attribute_groups/_all_docs

I am trying to compose the curl command to run the JSON Mango query from the other Linux Server.

I have my Mango Query in a file: "mangoReqPay" which ls -l tells me is 221 characters long.

{  "selector": {"status":"stable", "model":"PC-20",  "variant":{    "$in": ["15",  "30"]    }  },  "fields":["_id","_rev","status",  "model","variant","variant-type",  "oem","historicaloem","displaymodel",  "sactmodel"]}

Here is the command that I am trying to use.

curl -H "Content-Type: application/json" \
 -H "Content-Length: 221" \
 -X POST \
 -d mangoReqPay \
 -H "Host: http://my.server.com:5984/model_attribute_groups\_find"

When I submit this command, I get no response, it just sits there appearing to wait for more input.

Can someone give me a nudge in the right direction?

Thanks

Rich


Solution

  • You have not specified a URL. Your host name in "-H" parameter is NOT the url you want curl to request - it just sets the header.

    When I run the command I get the error (and rightly so):

    curl: no URL specified!
    

    Just specify the URL you want curl to fetch without any flags at the end (or at the beginning).

    Also you do not need "Content-Length: 221". If you want it to read from a file you start the filename with '@'