Reputation: 332
I am trying to use the CouchDB API to query a specific view. Here is what I am using:
$.post(targetURL,
{
"keys": ["Query Value"]
},
function (data, status) {
console.log("Data");
console.log(data);
}).catch((err) => {
console.log(err);
});
However, when running this I get this 415 code:
"bad_content_type", reason: "Content-Type must be application/json"
What am I doing wrong?
Upvotes: 1
Views: 51
Reputation: 465
I would try something like:
var dataModel = {
keys: ["Query Value"]
};
$.ajax({
url: 'http://xxxxxxxxx',
type: 'POST',
content: 'application/json',
dataType: 'json',
data: JSON.stringify(dataModel),
success: function(data, status, xhr){
}
});
Upvotes: 3