Hi,
How can I attach design doc payload if content type is JSON, not binary?
https://developer.couchbase.com/documentation/server/5.0/rest-api/rest-ddocs-create.html
I’m using Postman to send REST.
Hi,
How can I attach design doc payload if content type is JSON, not binary?
https://developer.couchbase.com/documentation/server/5.0/rest-api/rest-ddocs-create.html
I’m using Postman to send REST.
Hi @cooler_3105,
I don’t quite understand. That documentation page says the definition is JSON, and doesn’t say anything about binary.
Could you post an example of type of request you are trying to make (maybe a postman screenshot and the payload you are trying), and what kind of error message(s) you are getting?
hello @matthew.groves
curl -X POST -H “Content-Type: application/json” http://Administrator:123456@127.0.0.1:8092/EmployeeBucket/_design/dev_field -d @byfield.ddoc
above is my query but the error is
Warning: Couldn’t read data from file “byfield.ddoc”, this makes an empty
Warning: POST.
{“error”:“not_found”,“reason”:“missing”}
please can u help me out by solving this error
Hi @boby,
In the future, I’d recommend starting a new question instead of responding to a 2 year old topic.
That being said: this sounds like a curl error message.
Does the file “byfield.ddoc” exist? Do you have sufficient permission on it? Can you share the contents of byfield.ddoc? Also, what are you expecting to happen?
sorry sir. i wll do it from next time @matthew.groves
no sir.
actually i have a doubt that , i have created ddoc file (by text file ) but where to place that “byfield.ddoc” .
function (doc, meta)
{
if (doc.name)
{
emit(doc);
}
}
and this will the content of my ddoc .
and i have full permission
please help me out
I think there are two things going wrong here.
You should be using PUT instead of POST. See the documentation on Creating Design Documents
The body being set should be JSON and not raw JavaScript (as you can see in Getting Design Doc Information in the documentation). Something like this:
{
“views” : {
“byfield” : {
“map” : “function (doc, meta) { if (doc.name) { emit(doc); } }”
}
}
}
Hopefully this will help get you on the right track (I didn’t use curl to test this, by the way, I used Postman, which I find to be a much more useful tool for trying out endpoints like this).
Furthermore, I highly recommend that you start thinking about switching over to N1QL, as map/reduce views are definitely not recommended, aren’t really being further enhanced much, and are likely to be deprecated at some point.