jaxer trying to work with couchdb keep getting error 400

29 views
Skip to first unread message

bryan

unread,
Jun 28, 2011, 7:42:12 PM6/28/11
to Jaxer
Hi,

I am trying to create a new document in couchdb.

I do the following
var url = "http://user:pass...@127.0.0.1:5984/test/";
var body = {
"_id" : "newdarnid"
};


Jaxer.Web.post(url,body,{contentType: "application/json"});

this gets me the response {"error":"bad_request","reason":"invalid
UTF-8 JSON"}


I get the following working with Curl

curl -X POST http://username:pass...@127.0.0.1:5984/test/ -H "Content-
Type: application/json" -d "{\"_id\" : \"feed_1309302329298pantagruel
\", \"name\" : \"test1\"}"

but my various attempts with jaxer are not working. Can you give me an
example of the above that should work in jaxer - I suppose once I have
something working I can backtrack from there...

Thanks,
Bryan Rasmussen


bryan

unread,
Jun 29, 2011, 3:57:50 PM6/29/11
to Jaxer
Just to put it in for anyone else who ends up in the same situation,
it looks like I need to escape all the json in the same way I was
doing with the curl example below.

On Jun 29, 1:42 am, bryan <rasmussen.br...@gmail.com> wrote:
> Hi,
>
> I am trying to create a new document in couchdb.
>
> I do the following
> var url = "http://user:passw...@127.0.0.1:5984/test/";
>  var body = {
>   "_id" : "newdarnid"
>   };
>
>  Jaxer.Web.post(url,body,{contentType: "application/json"});
>
> this gets me the response {"error":"bad_request","reason":"invalid
> UTF-8 JSON"}
>
> I get the following working with Curl
>
> curl -X POST http://username:passw...@127.0.0.1:5984/test/ -H "Content-
Reply all
Reply to author
Forward
0 new messages