2 Replies Latest reply on Mar 31, 2014 9:35 AM by applebeary

    Why sometimes I could create 2 documents with same title using REST api v3 /contents service?

    applebeary

      Hi All,

       

      I have encountered a problem, not sure if anyone else have the same.

      Sometimes I create 2 documents with same title using REST api v3 /contents service.. but I only make the request once. The 2 documents have the same created date and time.

      Is this a bug or I should make some changes in my code?

       

      Thanks!

      Best Regards,

      Yulan

        • Re: Why sometimes I could create 2 documents with same title using REST api v3 /contents service?

          This isn't an issue I've heard before, any chance you could share the code.  My guess is that the code is getting invoked twice higher up, but if you can share some code and the context in which its invoked, we can try to figure it out. =)

            • Re: Why sometimes I could create 2 documents with same title using REST api v3 /contents service?
              applebeary

              Hi Ryan,

               

              Thanks for you reply!

               

              Yep, sure. This does not happen every time (most of time, I could still get 409 error status which is right), but it happened.

              So I am using a jQuery form plugin. Below is the related code:

               

              HTML part:

               

               

              <form id="withoutAttachment" style="visibility:hidden" enctype="multipart/form-data"><input type="text" id="json_only" name="json"/><input type="submit" value="submit"/></form>

               

              JS part:

               

              <script type="text/javascript" src="/servlet/JiveServlet/downloadBody/30697-102-1-75762/jquery.form.min.js"></script>

              <script>

              function create_doc(htmlContent){

              var jsondata="{'parent':'"+baseURL+"/places/"+placeId+"','content':{'type': 'text/html','text': '"+htmlContent+"'},'subject': '"+ads_Title+"','type': 'document','tags':['"+tag_Country+"','"+tag_Category+"','"+tag_Type+"']}";

              $j("#json_only").val(jsondata);

              $j("#withoutAttachment").submit();

              }

               

              function ShowRequest(formData, jqForm, options) {

                        return true;

                      }

               

               

              function AjaxError(e) {

                      if(e.status==409){alert("Please change the title. An advertisement with the same title already exists.");}

              else if(e.status==400){alert("An input field is malformed");}
                    else if(e.status==403){alert("Please log in again.");}

                      }

               

               

              function SubmitSuccesful(responseText, statusText) {

                       var doc_url=responseText.resources.html.ref;

                      window.location.replace(doc_url);

                      }   

              </script>

               

               

              I downloaded the form plugin from: http://malsup.com/jquery/form/

               

              Followed is the screenshot showing that 2 documents with the same title:

               

              3-31-2014 12-28-02 PM.jpg

               

              Let me know if I need to make any changes on the code.

              Thank you!

              Best Regards,

              Yulan