3

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.

Daniele B
  • 3,117
  • 2
  • 23
  • 46

1 Answers1

6

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.

Victor Nicollet
  • 24,361
  • 4
  • 58
  • 89