Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running cUrl cmd from Win7 doesn't work, but on Linux it does

Tags:

utf-8

couchdb

Like the title says. I'm sending a simple cUrl cmd from Win7 to CouchDB on my Linux box, and it doesn't work. But if I run the same command in Linux, it works. I'm sending this:

curl -X POST 192.168.2.5:5984/test/testdoc -d '{"owner":{"fname":"test","lname":"ing"}}'

From windows, it keeps giving me a "error: bad request, reason:invalid UTF-8 JSON". I can run GET commands from windows just fine, I just can't seem to POST to CouchDB.

like image 523
jkidv Avatar asked May 06 '10 19:05

jkidv


People also ask

Why is curl command not working?

We might have come across errors like “curl: command not found” while working in the terminal. This type of error comes due to only one reason: the relevant package is not installed. Curl is a very popular data transfer command-line utility used for downloading and uploading data from or to the server.

Does curl work on Windows?

cURL is free, open software that runs under various operating systems. This tutorial demonstrates cURL on a Windows 64-bit operating system that is enabled for the secure sockets layer (SSL). The authentication aspects of the Messaging Cloud Service require an SSL-enabled environment.


Video Answer


1 Answers

Unfortunately, the Windows shell (cmd.exe) uses quote marks differently from Mac OSX and Linux.

The simplest fix is to avoid single-quotes and use double quotes, with the double-quotes in the JSON document escaped:

curl -X PUT 192.168.2.5:5984/test/testdoc -d "{\"owner\":{\"fname\":\"test\",\"lname\":\"ing\"}}"
{"ok":true,"id":"testdoc","rev":"1-299729b3cb92a371136cb7331c66644d"}

Another option is to install a different shell such as Bash for Windows: http://win-bash.sourceforge.net/. Then you can follow documentation and do your own experiments more easily.

like image 123
JasonSmith Avatar answered Sep 18 '22 14:09

JasonSmith