Created
February 13, 2011 15:50
-
-
Save niklasfi/824790 to your computer and use it in GitHub Desktop.
this throws an error:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var req = http.request({host: '127.0.0.1', port: '5984', path: '/ms/', method: 'POST', 'Content-Type': 'application/json'},function(res){ | |
var sigma = ''; | |
res.on('data',function(chunk){sigma+=chunk}) | |
res.on('end',function(){ | |
console.log(sigma); //{"error":"bad_content_type","reason":"Content-Type must be application/json"} | |
var reply = JSON.parse(sigma); | |
if(reply.ok == "true") | |
callback(reply.id); | |
else | |
callback(null); | |
}) | |
}); | |
var data= JSON.stringify({'type':'file','modul':doc._id,'author': author, 'downloads':0}) | |
console.log(data); //{"type":"file","modul":"28d946b681df8ab17c2010193e001172","author":"Niklas Fischer","downloads":0} | |
req.end(data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@vs1145146:/var/www/mitschriften# curl -X POST -H "Content-Type: application/json" -d '{"type":"file","modul":"28d946b681df8ab17c2010193e001172","author":"Niklas Fischer"wnloads":"0"}' 127.0.0.1:5984/ms/ | |
{"ok":true,"id":"28d946b681df8ab17c2010193e004bf9","rev":"1-5ffe477691071504ca55bfa9fb997dd4" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment