0

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

  • das
  • model_attribute_groups
  • mydemo
  • registry
  • verifytestdb

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

1 Answers1

1

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 '@'

Ari Singh
  • 1,228
  • 7
  • 12
  • Thanks for the quick response, especially the part about prefixing the input file with '@'. That combined with a couple of tweaks of the URL and the addition of -u got me to success. Here is the working version of the curl command. `curl -H "Content-Type: application/json" \ -X POST -d @mangoReqPay \ -u myUserId \ http://my.server.boeing.com:5984/model_attribute_groups/_find` Now, onto understanding "rewrites"! – Richard Wood Mar 09 '18 at 15:43