What does the MarkLogic out of the box rest api return when deleting a document fails?2019 Community Moderator ElectionREST API error return good practicesWhat REST PUT/POST/DELETE calls should return by a convention?Returning RESTful response codes in PlayRESTful undeleteREST API 404: Bad URI, or Missing Resource?Setting permissions on a document using MarkLogic's REST APIDocument versioning with MarkLogic REST APIREST-API, proper HTTP status code for invalid DELETEMarkLogic v1/transactions create by REST APIWhat is the HTTP status return code for a successful DELETE statement in REST?

PTIJ: Who should I vote for? (21st Knesset Edition)

Interplanetary conflict, some disease destroys the ability to understand or appreciate music

Are ETF trackers fundamentally better than individual stocks?

Min function accepting varying number of arguments in C++17

Time travel from stationary position?

How do I hide Chekhov's Gun?

Do the common programs (for example: "ls", "cat") in Linux and BSD come from the same source code?

If I can solve Sudoku can I solve Travelling Salesman Problem(TSP)? If yes, how?

What are substitutions for coconut in curry?

Python if-else code style for reduced code for rounding floats

What did Alexander Pope mean by "Expletives their feeble Aid do join"?

Why Choose Less Effective Armour Types?

What's the meaning of “spike” in the context of “adrenaline spike”?

Do I need life insurance if I can cover my own funeral costs?

Use of undefined constant bloginfo

Why do passenger jet manufacturers design their planes with stall prevention systems?

My adviser wants to be the first author

Why would a flight no longer considered airworthy be redirected like this?

How to change two letters closest to a string and one letter immediately after a string using notepad++

Should we release the security issues we found in our product as CVE or we can just update those on weekly release notes?

How to write cleanly even if my character uses expletive language?

Define, (actually define) the "stability" and "energy" of a compound

Welcoming 2019 Pi day: How to draw the letter π?

Official degrees of earth’s rotation per day



What does the MarkLogic out of the box rest api return when deleting a document fails?



2019 Community Moderator ElectionREST API error return good practicesWhat REST PUT/POST/DELETE calls should return by a convention?Returning RESTful response codes in PlayRESTful undeleteREST API 404: Bad URI, or Missing Resource?Setting permissions on a document using MarkLogic's REST APIDocument versioning with MarkLogic REST APIREST-API, proper HTTP status code for invalid DELETEMarkLogic v1/transactions create by REST APIWhat is the HTTP status return code for a successful DELETE statement in REST?










1















The MarkLogic documentation gives information for a success response, but no information for a failed delete.



https://docs.marklogic.com/REST/DELETE/v1/documents



I would expect a 404 if the document doesn't exist, a 410 if it's already been deleted, or a 403 if I don't have authorization to delete the document.



From my limited testing, it seems I get a 204 if the document doesn't exist, and a 400 if I'm not authorized.










share|improve this question


























    1















    The MarkLogic documentation gives information for a success response, but no information for a failed delete.



    https://docs.marklogic.com/REST/DELETE/v1/documents



    I would expect a 404 if the document doesn't exist, a 410 if it's already been deleted, or a 403 if I don't have authorization to delete the document.



    From my limited testing, it seems I get a 204 if the document doesn't exist, and a 400 if I'm not authorized.










    share|improve this question
























      1












      1








      1








      The MarkLogic documentation gives information for a success response, but no information for a failed delete.



      https://docs.marklogic.com/REST/DELETE/v1/documents



      I would expect a 404 if the document doesn't exist, a 410 if it's already been deleted, or a 403 if I don't have authorization to delete the document.



      From my limited testing, it seems I get a 204 if the document doesn't exist, and a 400 if I'm not authorized.










      share|improve this question














      The MarkLogic documentation gives information for a success response, but no information for a failed delete.



      https://docs.marklogic.com/REST/DELETE/v1/documents



      I would expect a 404 if the document doesn't exist, a 410 if it's already been deleted, or a 403 if I don't have authorization to delete the document.



      From my limited testing, it seems I get a 204 if the document doesn't exist, and a 400 if I'm not authorized.







      rest marklogic http-delete






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 7 at 13:58









      TravisChambersTravisChambers

      141110




      141110






















          2 Answers
          2






          active

          oldest

          votes


















          1














          Some REST practioners assert the DELETE request should be idempotent. So long as the document doesn't exist after the operation finishes, the operation succeeded.



          That said, recent versions of the REST API allow a check parameter on document delete requests. If check is set to "exists," the operation should throw an error if the document doesn't exist.



          In passing, I don't see how the 404 and 410 cases could be distinguished, given that there's no operational state on the server.



          Hoping that helps,






          share|improve this answer























          • Right. To get the 404 or 410 I would have to do some magic. Instead of deleting the item, I'd delete it's contents, but leave the resource at it's original URI, and do a read before a delete. Alternatively, and I think this is the solution I'll be opting for, I won't actually delete the document, but I'll instead add it to a special deleted collection that doesn't show up in search.

            – TravisChambers
            Mar 9 at 2:13


















          0














          You could take an API-first approach and build your own great REST APIs directly on MarkLogic where you take full control over the URI Path as well as response codes and anything else for that matter with XQRS.



          declare
          %rest:DELETE
          %rest:path("/db/$uri=.*")
          %xdmp:update
          function delete-doc($uri as xs:string)
          if(fn:doc-available($uri)) then (
          xdmp:document-delete($uri),
          <rest:response>
          <http:response status="410" message="Gone"/>
          </rest:response>
          )
          else (
          <rest:response>
          <http:response status="404" message="Not Found"/>
          </rest:response>
          )
          ;





          share|improve this answer























          • i see what you're saying, but how can i return a 404 not found if i don't know the document wasn't found? i get a 204 success whether the document was found or not. i am building my own rest api on top of MarkLogic's and I'm trying to find out all the possible failed responses MarkLogic might send back, as well as how I can give users of my API accurate status codes.

            – TravisChambers
            Mar 7 at 15:41






          • 1





            The approach I am suggesting involves building your own REST API which is directly served from MarkLogic Server itself using the XQRS framework over and above writing a Middle Tier component that interfaces with MarkLogic via MarkLogic's REST API. This approach would give you 100% control over MarkLogic as you're able to invoke any of MarkLogic's thousands of functions as well as having total control of what your REST APIs looks like. The XQRS framework allows you to build REST APIs in a manner that's similar to the very popular JAX-RS, whilst giving total freedom with the database.

            – Charles Foster
            Mar 7 at 15:55












          • I'm with you now. I'll consider it, but rewriting the MarkLogic out of the box REST apis is not something I want to do. Especially in xquery.

            – TravisChambers
            Mar 7 at 17:47










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55045542%2fwhat-does-the-marklogic-out-of-the-box-rest-api-return-when-deleting-a-document%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Some REST practioners assert the DELETE request should be idempotent. So long as the document doesn't exist after the operation finishes, the operation succeeded.



          That said, recent versions of the REST API allow a check parameter on document delete requests. If check is set to "exists," the operation should throw an error if the document doesn't exist.



          In passing, I don't see how the 404 and 410 cases could be distinguished, given that there's no operational state on the server.



          Hoping that helps,






          share|improve this answer























          • Right. To get the 404 or 410 I would have to do some magic. Instead of deleting the item, I'd delete it's contents, but leave the resource at it's original URI, and do a read before a delete. Alternatively, and I think this is the solution I'll be opting for, I won't actually delete the document, but I'll instead add it to a special deleted collection that doesn't show up in search.

            – TravisChambers
            Mar 9 at 2:13















          1














          Some REST practioners assert the DELETE request should be idempotent. So long as the document doesn't exist after the operation finishes, the operation succeeded.



          That said, recent versions of the REST API allow a check parameter on document delete requests. If check is set to "exists," the operation should throw an error if the document doesn't exist.



          In passing, I don't see how the 404 and 410 cases could be distinguished, given that there's no operational state on the server.



          Hoping that helps,






          share|improve this answer























          • Right. To get the 404 or 410 I would have to do some magic. Instead of deleting the item, I'd delete it's contents, but leave the resource at it's original URI, and do a read before a delete. Alternatively, and I think this is the solution I'll be opting for, I won't actually delete the document, but I'll instead add it to a special deleted collection that doesn't show up in search.

            – TravisChambers
            Mar 9 at 2:13













          1












          1








          1







          Some REST practioners assert the DELETE request should be idempotent. So long as the document doesn't exist after the operation finishes, the operation succeeded.



          That said, recent versions of the REST API allow a check parameter on document delete requests. If check is set to "exists," the operation should throw an error if the document doesn't exist.



          In passing, I don't see how the 404 and 410 cases could be distinguished, given that there's no operational state on the server.



          Hoping that helps,






          share|improve this answer













          Some REST practioners assert the DELETE request should be idempotent. So long as the document doesn't exist after the operation finishes, the operation succeeded.



          That said, recent versions of the REST API allow a check parameter on document delete requests. If check is set to "exists," the operation should throw an error if the document doesn't exist.



          In passing, I don't see how the 404 and 410 cases could be distinguished, given that there's no operational state on the server.



          Hoping that helps,







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 8 at 1:24









          ehennumehennum

          5,44697




          5,44697












          • Right. To get the 404 or 410 I would have to do some magic. Instead of deleting the item, I'd delete it's contents, but leave the resource at it's original URI, and do a read before a delete. Alternatively, and I think this is the solution I'll be opting for, I won't actually delete the document, but I'll instead add it to a special deleted collection that doesn't show up in search.

            – TravisChambers
            Mar 9 at 2:13

















          • Right. To get the 404 or 410 I would have to do some magic. Instead of deleting the item, I'd delete it's contents, but leave the resource at it's original URI, and do a read before a delete. Alternatively, and I think this is the solution I'll be opting for, I won't actually delete the document, but I'll instead add it to a special deleted collection that doesn't show up in search.

            – TravisChambers
            Mar 9 at 2:13
















          Right. To get the 404 or 410 I would have to do some magic. Instead of deleting the item, I'd delete it's contents, but leave the resource at it's original URI, and do a read before a delete. Alternatively, and I think this is the solution I'll be opting for, I won't actually delete the document, but I'll instead add it to a special deleted collection that doesn't show up in search.

          – TravisChambers
          Mar 9 at 2:13





          Right. To get the 404 or 410 I would have to do some magic. Instead of deleting the item, I'd delete it's contents, but leave the resource at it's original URI, and do a read before a delete. Alternatively, and I think this is the solution I'll be opting for, I won't actually delete the document, but I'll instead add it to a special deleted collection that doesn't show up in search.

          – TravisChambers
          Mar 9 at 2:13













          0














          You could take an API-first approach and build your own great REST APIs directly on MarkLogic where you take full control over the URI Path as well as response codes and anything else for that matter with XQRS.



          declare
          %rest:DELETE
          %rest:path("/db/$uri=.*")
          %xdmp:update
          function delete-doc($uri as xs:string)
          if(fn:doc-available($uri)) then (
          xdmp:document-delete($uri),
          <rest:response>
          <http:response status="410" message="Gone"/>
          </rest:response>
          )
          else (
          <rest:response>
          <http:response status="404" message="Not Found"/>
          </rest:response>
          )
          ;





          share|improve this answer























          • i see what you're saying, but how can i return a 404 not found if i don't know the document wasn't found? i get a 204 success whether the document was found or not. i am building my own rest api on top of MarkLogic's and I'm trying to find out all the possible failed responses MarkLogic might send back, as well as how I can give users of my API accurate status codes.

            – TravisChambers
            Mar 7 at 15:41






          • 1





            The approach I am suggesting involves building your own REST API which is directly served from MarkLogic Server itself using the XQRS framework over and above writing a Middle Tier component that interfaces with MarkLogic via MarkLogic's REST API. This approach would give you 100% control over MarkLogic as you're able to invoke any of MarkLogic's thousands of functions as well as having total control of what your REST APIs looks like. The XQRS framework allows you to build REST APIs in a manner that's similar to the very popular JAX-RS, whilst giving total freedom with the database.

            – Charles Foster
            Mar 7 at 15:55












          • I'm with you now. I'll consider it, but rewriting the MarkLogic out of the box REST apis is not something I want to do. Especially in xquery.

            – TravisChambers
            Mar 7 at 17:47















          0














          You could take an API-first approach and build your own great REST APIs directly on MarkLogic where you take full control over the URI Path as well as response codes and anything else for that matter with XQRS.



          declare
          %rest:DELETE
          %rest:path("/db/$uri=.*")
          %xdmp:update
          function delete-doc($uri as xs:string)
          if(fn:doc-available($uri)) then (
          xdmp:document-delete($uri),
          <rest:response>
          <http:response status="410" message="Gone"/>
          </rest:response>
          )
          else (
          <rest:response>
          <http:response status="404" message="Not Found"/>
          </rest:response>
          )
          ;





          share|improve this answer























          • i see what you're saying, but how can i return a 404 not found if i don't know the document wasn't found? i get a 204 success whether the document was found or not. i am building my own rest api on top of MarkLogic's and I'm trying to find out all the possible failed responses MarkLogic might send back, as well as how I can give users of my API accurate status codes.

            – TravisChambers
            Mar 7 at 15:41






          • 1





            The approach I am suggesting involves building your own REST API which is directly served from MarkLogic Server itself using the XQRS framework over and above writing a Middle Tier component that interfaces with MarkLogic via MarkLogic's REST API. This approach would give you 100% control over MarkLogic as you're able to invoke any of MarkLogic's thousands of functions as well as having total control of what your REST APIs looks like. The XQRS framework allows you to build REST APIs in a manner that's similar to the very popular JAX-RS, whilst giving total freedom with the database.

            – Charles Foster
            Mar 7 at 15:55












          • I'm with you now. I'll consider it, but rewriting the MarkLogic out of the box REST apis is not something I want to do. Especially in xquery.

            – TravisChambers
            Mar 7 at 17:47













          0












          0








          0







          You could take an API-first approach and build your own great REST APIs directly on MarkLogic where you take full control over the URI Path as well as response codes and anything else for that matter with XQRS.



          declare
          %rest:DELETE
          %rest:path("/db/$uri=.*")
          %xdmp:update
          function delete-doc($uri as xs:string)
          if(fn:doc-available($uri)) then (
          xdmp:document-delete($uri),
          <rest:response>
          <http:response status="410" message="Gone"/>
          </rest:response>
          )
          else (
          <rest:response>
          <http:response status="404" message="Not Found"/>
          </rest:response>
          )
          ;





          share|improve this answer













          You could take an API-first approach and build your own great REST APIs directly on MarkLogic where you take full control over the URI Path as well as response codes and anything else for that matter with XQRS.



          declare
          %rest:DELETE
          %rest:path("/db/$uri=.*")
          %xdmp:update
          function delete-doc($uri as xs:string)
          if(fn:doc-available($uri)) then (
          xdmp:document-delete($uri),
          <rest:response>
          <http:response status="410" message="Gone"/>
          </rest:response>
          )
          else (
          <rest:response>
          <http:response status="404" message="Not Found"/>
          </rest:response>
          )
          ;






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 7 at 15:38









          Charles FosterCharles Foster

          18914




          18914












          • i see what you're saying, but how can i return a 404 not found if i don't know the document wasn't found? i get a 204 success whether the document was found or not. i am building my own rest api on top of MarkLogic's and I'm trying to find out all the possible failed responses MarkLogic might send back, as well as how I can give users of my API accurate status codes.

            – TravisChambers
            Mar 7 at 15:41






          • 1





            The approach I am suggesting involves building your own REST API which is directly served from MarkLogic Server itself using the XQRS framework over and above writing a Middle Tier component that interfaces with MarkLogic via MarkLogic's REST API. This approach would give you 100% control over MarkLogic as you're able to invoke any of MarkLogic's thousands of functions as well as having total control of what your REST APIs looks like. The XQRS framework allows you to build REST APIs in a manner that's similar to the very popular JAX-RS, whilst giving total freedom with the database.

            – Charles Foster
            Mar 7 at 15:55












          • I'm with you now. I'll consider it, but rewriting the MarkLogic out of the box REST apis is not something I want to do. Especially in xquery.

            – TravisChambers
            Mar 7 at 17:47

















          • i see what you're saying, but how can i return a 404 not found if i don't know the document wasn't found? i get a 204 success whether the document was found or not. i am building my own rest api on top of MarkLogic's and I'm trying to find out all the possible failed responses MarkLogic might send back, as well as how I can give users of my API accurate status codes.

            – TravisChambers
            Mar 7 at 15:41






          • 1





            The approach I am suggesting involves building your own REST API which is directly served from MarkLogic Server itself using the XQRS framework over and above writing a Middle Tier component that interfaces with MarkLogic via MarkLogic's REST API. This approach would give you 100% control over MarkLogic as you're able to invoke any of MarkLogic's thousands of functions as well as having total control of what your REST APIs looks like. The XQRS framework allows you to build REST APIs in a manner that's similar to the very popular JAX-RS, whilst giving total freedom with the database.

            – Charles Foster
            Mar 7 at 15:55












          • I'm with you now. I'll consider it, but rewriting the MarkLogic out of the box REST apis is not something I want to do. Especially in xquery.

            – TravisChambers
            Mar 7 at 17:47
















          i see what you're saying, but how can i return a 404 not found if i don't know the document wasn't found? i get a 204 success whether the document was found or not. i am building my own rest api on top of MarkLogic's and I'm trying to find out all the possible failed responses MarkLogic might send back, as well as how I can give users of my API accurate status codes.

          – TravisChambers
          Mar 7 at 15:41





          i see what you're saying, but how can i return a 404 not found if i don't know the document wasn't found? i get a 204 success whether the document was found or not. i am building my own rest api on top of MarkLogic's and I'm trying to find out all the possible failed responses MarkLogic might send back, as well as how I can give users of my API accurate status codes.

          – TravisChambers
          Mar 7 at 15:41




          1




          1





          The approach I am suggesting involves building your own REST API which is directly served from MarkLogic Server itself using the XQRS framework over and above writing a Middle Tier component that interfaces with MarkLogic via MarkLogic's REST API. This approach would give you 100% control over MarkLogic as you're able to invoke any of MarkLogic's thousands of functions as well as having total control of what your REST APIs looks like. The XQRS framework allows you to build REST APIs in a manner that's similar to the very popular JAX-RS, whilst giving total freedom with the database.

          – Charles Foster
          Mar 7 at 15:55






          The approach I am suggesting involves building your own REST API which is directly served from MarkLogic Server itself using the XQRS framework over and above writing a Middle Tier component that interfaces with MarkLogic via MarkLogic's REST API. This approach would give you 100% control over MarkLogic as you're able to invoke any of MarkLogic's thousands of functions as well as having total control of what your REST APIs looks like. The XQRS framework allows you to build REST APIs in a manner that's similar to the very popular JAX-RS, whilst giving total freedom with the database.

          – Charles Foster
          Mar 7 at 15:55














          I'm with you now. I'll consider it, but rewriting the MarkLogic out of the box REST apis is not something I want to do. Especially in xquery.

          – TravisChambers
          Mar 7 at 17:47





          I'm with you now. I'll consider it, but rewriting the MarkLogic out of the box REST apis is not something I want to do. Especially in xquery.

          – TravisChambers
          Mar 7 at 17:47

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55045542%2fwhat-does-the-marklogic-out-of-the-box-rest-api-return-when-deleting-a-document%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

          2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme