Search code examples
phpcurlcloudant

can't put a document on cloudant with curl


In php, I have this working :

$results = shell_exec('c:/xamppp/apache/bin/curl -X POST 
"https://xxx:[email protected]/essai" -d {} -H "Content-Type: 
application/json"');

It works and a blank document appears in cloudant. But when I try :

{"toto":"123"}

to insert a non empty doc, it fails ({"error":"bad_request","reason":"invalid UTF-8 JSON"})

What is my mistake?


Solution

  • Try putting the contents for -d in single quotes (escaped since your calling the command with single quotes):

    -d \'{"toto": "123"}\'