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

          Thal And Out Agency railway station See also References External links Navigation menuOfficial Web Site of Pakistan RailwaysArchivedOfficial Web Site of Pakistan Railwayseeexpanding ite

          Posting a File and Associated Data to a RESTful WebService preferably as JSON2019 Community Moderator ElectionREST URI convention - Singular or plural name of resource while creating itUploading both data and files in one form using Ajax?How do I upload a file with metadata using a REST web service?REST API - file (ie images) processing - best practicesSpring: JSON data and file in the same requestREST API Put large dataPosting a file and JSON data to Spring rest serviceRESTful Web Service Upload/Download Large Data With JSONREST API Design sending JSON data and a file to the api in same requestPost JSONArray to REST servicePUT vs. POST in RESTParsing values from a JSON file?JavaScript/jQuery to download file via POST with JSON dataHow do I upload a file with metadata using a REST web service?How to POST JSON data with Curl from Terminal/Commandline to Test Spring REST?Separate REST JSON API server and client?what's the correct way to send a file from REST web service to client?How do I write JSON data to a file?What is “406-Not Acceptable Response” in HTTP?REST API - file (ie images) processing - best practices

          How can I change the color of pagination dots of UIPageControl?How to change UIPageControl dotsIs there a way to change page indicator dots colorCustomize dot with image of UIPageControl at index 0 of UIPageControlNo visible @interface for 'NSObject<PageControlDelegate>' declares the selector 'pageControlPageDidChange:'How to change the color of pagination dots in UIPageControl with a different color per pagepagecontrol indicator custom image instead of DefaultChanging the colour of UIPageControl dots in MonoTouchpagecontrol selectable page visibility color?Alternative way to load ViewControllers on a UIPageControlHow to set only layer.border-color for UIpage control dots in swiftHow can I develop for iPhone using a Windows development machine?How to change the name of an iOS app?UITableView - change section header coloruipagecontrol indicator(dot)issueCustom UIPageControl dots color not changingchange the interspace between UIPageControl dotsHow to change Status Bar text color in iOSHow can I change image tintColor in iOS and WatchKitUIPageControl dots with larger space in between each dotsHow to change the color of pagination dots in UIPageControl with a different color per page