Without an example it's hard to tell why it doesn't work. The initial
guess is it's because you might have fetched attachments as stubs and
not their full body.

For example by default fetching a doc we might get:

   "_attachments": {
        "att1": {
            "content_type": "application/json",
            "digest": "md5-Ghxmlil8kHHM0/6YedoKwQ==",
            "length": 10,
            "revpos": 3,
            "stub": true
        }
    }


Notice how that doesn't contain any attachment data. But if you use
attachments=true you do get them

  "_attachments": {
    "att1": {
      "content_type": "application/json",
      "revpos": 3,
      "digest": "md5-Ghxmlil8kHHM0/6YedoKwQ==",
      "data": "eyJjIjogImQifQ=="
    }
  }

So make sure to use the second form if you intend to clone the
document with all of its attachments

Cheers,
-Nick

On Wed, Sep 29, 2021 at 3:09 PM Erik Verheul <[email protected]> wrote:
>
> Hi all,
>
> I tried do clone multiple documents, some with attachments,  by creating a 
> new _id and a copy of the fields from the original including "_attachments".
> The _bulk_docs post request to save the cloned documents failed with status 
> code 412. If no document has an attachment all is fine.
>
> How can I avoid this error?
>
> Any help would be very much appreciated.
> Thanks,
> Erik
>
>

Reply via email to