Does it consider bad practice to return the remaining of a collection after DELETE





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















Assuming we have a rest api, and a collection (with maximum 15 items).
The client is issuing a DELETE of one of the items in the collection.
Is it consider bad practice to return the remaining items in the collection? Should the DELETE return always empty body? If it is not a bad practice, what is the right status code?



My main question is, having a list of items, I DELETE one, is it ok to return a list of the remaining items?










share|improve this question































    1















    Assuming we have a rest api, and a collection (with maximum 15 items).
    The client is issuing a DELETE of one of the items in the collection.
    Is it consider bad practice to return the remaining items in the collection? Should the DELETE return always empty body? If it is not a bad practice, what is the right status code?



    My main question is, having a list of items, I DELETE one, is it ok to return a list of the remaining items?










    share|improve this question



























      1












      1








      1








      Assuming we have a rest api, and a collection (with maximum 15 items).
      The client is issuing a DELETE of one of the items in the collection.
      Is it consider bad practice to return the remaining items in the collection? Should the DELETE return always empty body? If it is not a bad practice, what is the right status code?



      My main question is, having a list of items, I DELETE one, is it ok to return a list of the remaining items?










      share|improve this question
















      Assuming we have a rest api, and a collection (with maximum 15 items).
      The client is issuing a DELETE of one of the items in the collection.
      Is it consider bad practice to return the remaining items in the collection? Should the DELETE return always empty body? If it is not a bad practice, what is the right status code?



      My main question is, having a list of items, I DELETE one, is it ok to return a list of the remaining items?







      rest http






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 '18 at 13:32







      Avraam Mavridis

















      asked Nov 16 '18 at 13:21









      Avraam MavridisAvraam Mavridis

      4,5231152104




      4,5231152104
























          2 Answers
          2






          active

          oldest

          votes


















          2














          As defined in RFC 7231:




          If a DELETE method is successfully applied, the origin server
          SHOULD send a 202 (Accepted) status code if the action will likely
          succeed but has not yet been enacted, a 204 (No Content) status
          code if the action has been enacted and no further information is
          to be supplied, or a 200 (OK) status code if the action has been
          enacted and the response message includes a representation
          describing the status.




          Mozilla has an example for it:



          HTTP/1.1 200 OK 
          Date: Wed, 21 Oct 2015 07:28:00 GMT

          <html>
          <body>
          <h1>File deleted.</h1>
          </body>
          </html>





          share|improve this answer































            0














            The way I see it, if your collection is a resource in and of itself, then a DELETE should delete the entirety of the collection (not a part of it) in which case I'd return 200 OK upon successful deletion.



            If you want to DELETE one specific resource (not a collection), then delete that at its own URI and return 200 OK as well.



            Just don't usurp the DELETE to essentially update a collection.



            So no. Don't return the remainder of the collection. Return a status code.






            share|improve this answer
























              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%2f53338743%2fdoes-it-consider-bad-practice-to-return-the-remaining-of-a-collection-after-dele%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









              2














              As defined in RFC 7231:




              If a DELETE method is successfully applied, the origin server
              SHOULD send a 202 (Accepted) status code if the action will likely
              succeed but has not yet been enacted, a 204 (No Content) status
              code if the action has been enacted and no further information is
              to be supplied, or a 200 (OK) status code if the action has been
              enacted and the response message includes a representation
              describing the status.




              Mozilla has an example for it:



              HTTP/1.1 200 OK 
              Date: Wed, 21 Oct 2015 07:28:00 GMT

              <html>
              <body>
              <h1>File deleted.</h1>
              </body>
              </html>





              share|improve this answer




























                2














                As defined in RFC 7231:




                If a DELETE method is successfully applied, the origin server
                SHOULD send a 202 (Accepted) status code if the action will likely
                succeed but has not yet been enacted, a 204 (No Content) status
                code if the action has been enacted and no further information is
                to be supplied, or a 200 (OK) status code if the action has been
                enacted and the response message includes a representation
                describing the status.




                Mozilla has an example for it:



                HTTP/1.1 200 OK 
                Date: Wed, 21 Oct 2015 07:28:00 GMT

                <html>
                <body>
                <h1>File deleted.</h1>
                </body>
                </html>





                share|improve this answer


























                  2












                  2








                  2







                  As defined in RFC 7231:




                  If a DELETE method is successfully applied, the origin server
                  SHOULD send a 202 (Accepted) status code if the action will likely
                  succeed but has not yet been enacted, a 204 (No Content) status
                  code if the action has been enacted and no further information is
                  to be supplied, or a 200 (OK) status code if the action has been
                  enacted and the response message includes a representation
                  describing the status.




                  Mozilla has an example for it:



                  HTTP/1.1 200 OK 
                  Date: Wed, 21 Oct 2015 07:28:00 GMT

                  <html>
                  <body>
                  <h1>File deleted.</h1>
                  </body>
                  </html>





                  share|improve this answer













                  As defined in RFC 7231:




                  If a DELETE method is successfully applied, the origin server
                  SHOULD send a 202 (Accepted) status code if the action will likely
                  succeed but has not yet been enacted, a 204 (No Content) status
                  code if the action has been enacted and no further information is
                  to be supplied, or a 200 (OK) status code if the action has been
                  enacted and the response message includes a representation
                  describing the status.




                  Mozilla has an example for it:



                  HTTP/1.1 200 OK 
                  Date: Wed, 21 Oct 2015 07:28:00 GMT

                  <html>
                  <body>
                  <h1>File deleted.</h1>
                  </body>
                  </html>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 16 '18 at 13:27









                  maio290maio290

                  2,103615




                  2,103615

























                      0














                      The way I see it, if your collection is a resource in and of itself, then a DELETE should delete the entirety of the collection (not a part of it) in which case I'd return 200 OK upon successful deletion.



                      If you want to DELETE one specific resource (not a collection), then delete that at its own URI and return 200 OK as well.



                      Just don't usurp the DELETE to essentially update a collection.



                      So no. Don't return the remainder of the collection. Return a status code.






                      share|improve this answer




























                        0














                        The way I see it, if your collection is a resource in and of itself, then a DELETE should delete the entirety of the collection (not a part of it) in which case I'd return 200 OK upon successful deletion.



                        If you want to DELETE one specific resource (not a collection), then delete that at its own URI and return 200 OK as well.



                        Just don't usurp the DELETE to essentially update a collection.



                        So no. Don't return the remainder of the collection. Return a status code.






                        share|improve this answer


























                          0












                          0








                          0







                          The way I see it, if your collection is a resource in and of itself, then a DELETE should delete the entirety of the collection (not a part of it) in which case I'd return 200 OK upon successful deletion.



                          If you want to DELETE one specific resource (not a collection), then delete that at its own URI and return 200 OK as well.



                          Just don't usurp the DELETE to essentially update a collection.



                          So no. Don't return the remainder of the collection. Return a status code.






                          share|improve this answer













                          The way I see it, if your collection is a resource in and of itself, then a DELETE should delete the entirety of the collection (not a part of it) in which case I'd return 200 OK upon successful deletion.



                          If you want to DELETE one specific resource (not a collection), then delete that at its own URI and return 200 OK as well.



                          Just don't usurp the DELETE to essentially update a collection.



                          So no. Don't return the remainder of the collection. Return a status code.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 16 '18 at 13:30









                          Wim OmbeletsWim Ombelets

                          3,68033246




                          3,68033246






























                              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%2f53338743%2fdoes-it-consider-bad-practice-to-return-the-remaining-of-a-collection-after-dele%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

                              Florida Star v. B. J. F.

                              Error while running script in elastic search , gateway timeout

                              Adding quotations to stringified JSON object values