Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

couchdb POST method not supported in local instance

Tags:

couchdb

My local instance of couchdb seems not to support the POST method.

This is the answer I have from chrome dev tools

POST http://localhost:5984/epos-couch/_design/epos-couch/_view/ri 415 (Unsupported Media Type)

the code in use is a simple ajax request with post method set:

$.ajax({ 
                    async: true, 
                    url: ajaxURL,
                    type:"POST",
                    data:.....,
                    dataType: 'json',
                    timeout:5000,
                    success:function(response){

                        riResponseList=response.rows;
                        },
                    error:function(){
                        alert('fetching error');
                        }
                    });

I'm pretty sure the problem is in my local instance because running such code on cloudant.com everyhing works fine.

So my question is: how can I set my local instance of couchdb to support the POST method?

I searched on the interet a bit (http://wiki.apache.org/couchdb, http://guide.couchdb.org/) but couln't find an answer.

like image 316
Daniele B Avatar asked Jan 21 '26 23:01

Daniele B


1 Answers

You need to specify contentType: "application/json" in your $.ajax call, as some configurations of CouchDB choke when they receive a non-application/json POST body.

like image 169
Victor Nicollet Avatar answered Jan 24 '26 21:01

Victor Nicollet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!