marklogic - How to delete a collection via a PATCH to the REST interface? - Stack Overflow

admin2025-04-21  2

I'm trying to delete one of several collections on a document by submitting a patch to the REST interface. It seems to succeed, but the collection remains and I can't figure out why.

This is the patch I'm trying to apply:

<rapi:patch xmlns:rapi=";>
    <rapi:delete select="/rapi:metadata/rapi:collections">
        <rapi:collection>;/rapi:collection>
    </rapi:delete>
</rapi:patch>

And the call to the API:

curl -u username:password -X PATCH -H "Content-Type: application/xml" -d "@./payload.xml"
     "=/path/to/file.xml?category=metadata"

I get a response of 204 Metadata Updated, but the collection is not deleted. I've tried also category=collections and both, but no effect. There's no example of a patch-delete in the documentation I can find, so I'm wondering if I'm missing an attribute or something.

I'm trying to delete one of several collections on a document by submitting a patch to the REST interface. It seems to succeed, but the collection remains and I can't figure out why.

This is the patch I'm trying to apply:

<rapi:patch xmlns:rapi="http://marklogic.com/rest-api">
    <rapi:delete select="/rapi:metadata/rapi:collections">
        <rapi:collection>http://example.com/somecollection</rapi:collection>
    </rapi:delete>
</rapi:patch>

And the call to the API:

curl -u username:password -X PATCH -H "Content-Type: application/xml" -d "@./payload.xml"
     "http://myserver.example.com/v1/documents?uri=/path/to/file.xml?category=metadata"

I get a response of 204 Metadata Updated, but the collection is not deleted. I've tried also category=collections and both, but no effect. There's no example of a patch-delete in the documentation I can find, so I'm wondering if I'm missing an attribute or something.

Share Improve this question asked Jan 22 at 23:06 eaolsoneaolson 15.1k7 gold badges45 silver badges60 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

I had the patch syntax wrong. Target the collection being deleted in the @select attribute

<rapi:patch xmlns:rapi="http://marklogic.com/rest-api">
    <rapi:delete select="/rapi:metadata/rapi:collections/rapi:collection[./text() eq
        'http://example.com/somecollection']" />
</rapi:patch>
转载请注明原文地址:http://anycun.com/QandA/1745224326a90439.html