<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Adding again aerogear list.<br>
      I think that we must discuss with the team (aerogear) on how we
      can/must handle a proper 201 response.<br>
      &nbsp;<br>
      On 12/17/2013 09:58 AM, Ivan St. Ivanov wrote:<br>
    </div>
    <blockquote
cite="mid:CACYLA9FG=c_c8oOd75HuAqc3n1wd7L5iG4T1zv7m42W74ATzAw@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi!
        <div><br>
        </div>
        <div>I think that the 'right' approach is to respond with 201
          (created) and return a URI to the newly created resource.</div>
        <div><br>
        </div>
        <div>Cheers,</div>
        <div>Ivan</div>
      </div>
      <div class="gmail_extra">
        <br>
        <br>
        <div class="gmail_quote">On Tue, Dec 17, 2013 at 12:58 AM,
          Lincoln Baxter, III <span dir="ltr">&lt;<a
              moz-do-not-send="true"
              href="mailto:lincolnbaxter@gmail.com" target="_blank">lincolnbaxter@gmail.com</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">Either is typical, but I think that most
              "pure" restifarians would favor the 201.</div>
            <div class="gmail_extra">
              <div>
                <div class="h5"><br>
                  <br>
                  <div class="gmail_quote">On Mon, Dec 16, 2013 at 5:41
                    PM, Burr Sutter <span dir="ltr">&lt;<a
                        moz-do-not-send="true"
                        href="mailto:bsutter@redhat.com" target="_blank">bsutter@redhat.com</a>&gt;</span>
                    wrote:<br>
                    <blockquote class="gmail_quote" style="margin:0 0 0
                      .8ex;border-left:1px #ccc solid;padding-left:1ex">
                      <div style="word-wrap:break-word">I need to find
                        my REST bible - what is typical to respond to
                        the POST with the JSON-serialized entity that
                        was originally POST'd or to simply respond with
                        a basic acknowledgement (http 201)?
                        <div>
                          <div>
                            <div><br>
                            </div>
                            <div><br>
                              <div>
                                <div>On Dec 16, 2013, at 4:25 PM, Vineet
                                  Reynolds Pereira &lt;<a
                                    moz-do-not-send="true"
                                    href="mailto:vpereira@redhat.com"
                                    target="_blank">vpereira@redhat.com</a>&gt;
                                  wrote:</div>
                                <br>
                                <blockquote type="cite">
                                  <div
style="font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Adding
                                    forge-dev.<br>
                                    <br>
                                    ----- Original Message -----<br>
                                    <blockquote type="cite">From: "Burr
                                      Sutter" &lt;<a
                                        moz-do-not-send="true"
                                        href="mailto:bsutter@redhat.com"
                                        target="_blank">bsutter@redhat.com</a>&gt;<br>
                                      To: "AeroGear Developer Mailing
                                      List" &lt;<a
                                        moz-do-not-send="true"
                                        href="mailto:aerogear-dev@lists.jboss.org"
                                        target="_blank">aerogear-dev@lists.jboss.org</a>&gt;<br>
                                      Sent: Tuesday, December 17, 2013
                                      1:59:41 AM<br>
                                      Subject: Re: [aerogear-dev]
                                      Aerogear.js for CRUD<br>
                                      <br>
                                      That seems to do the trick - now,
                                      where do we apply the fix? :-)<br>
                                    </blockquote>
                                    <br>
                                    Well, ideally this would be a
                                    feature request in Forge to support
                                    a new type<br>
                                    of a REST resource. But a couple of
                                    modified lines might not warrant it.<br>
                                    <br>
                                    It would be better to treat this as
                                    a flag to be enabled during REST
                                    resource<br>
                                    scaffolding. It would allow users to
                                    choose how the resource behaves -<br>
                                    * send a 201 response with Location
                                    header,<span>&nbsp;</span><br>
                                    * send a 201 response with Location
                                    header and also a response entity.<br>
                                    <br>
                                    It would most likely be addressed in
                                    Forge 2.<br>
                                    <br>
                                    <blockquote type="cite"><br>
                                      On Dec 16, 2013, at 3:06 PM,
                                      Vineet Reynolds Pereira &lt; <a
                                        moz-do-not-send="true"
                                        href="mailto:vpereira@redhat.com"
                                        target="_blank">vpereira@redhat.com</a>
                                      &gt;<br>
                                      wrote:<br>
                                      <br>
                                      <br>
                                      <br>
                                      <br>
                                      <br>
                                      <br>
                                      ----- Original Message -----<br>
                                      <br>
                                      <br>
                                      From: "Lucas Holmquist" &lt; <a
                                        moz-do-not-send="true"
                                        href="mailto:lholmqui@redhat.com"
                                        target="_blank">lholmqui@redhat.com</a>
                                      &gt;<br>
                                      To: "AeroGear Developer Mailing
                                      List" &lt; <a
                                        moz-do-not-send="true"
                                        href="mailto:aerogear-dev@lists.jboss.org"
                                        target="_blank">aerogear-dev@lists.jboss.org</a>
                                      &gt;<br>
                                      Cc: "Vineet Reynolds Pereira" &lt;
                                      <a moz-do-not-send="true"
                                        href="mailto:vpereira@redhat.com"
                                        target="_blank">vpereira@redhat.com</a>
                                      &gt;<br>
                                      Sent: Tuesday, December 17, 2013
                                      12:53:25 AM<br>
                                      Subject: Re: [aerogear-dev]
                                      Aerogear.js for CRUD<br>
                                      <br>
                                      <br>
                                      On Dec 16, 2013, at 1:52 PM, Burr
                                      Sutter &lt; <a
                                        moz-do-not-send="true"
                                        href="mailto:bsutter@redhat.com"
                                        target="_blank">bsutter@redhat.com</a>
                                      &gt; wrote:<br>
                                      <br>
                                      <br>
                                      <br>
                                      Adding Vineet as he has spent time
                                      on the Forge REST scaffolding.<br>
                                      <br>
                                      On Dec 16, 2013, at 7:01 AM,
                                      Sebastien Blanc &lt; <a
                                        moz-do-not-send="true"
                                        href="mailto:scm.blanc@gmail.com"
                                        target="_blank">scm.blanc@gmail.com</a>
                                      &gt; wrote:<br>
                                      <br>
                                      <br>
                                      <br>
                                      Burr,<br>
                                      I've added some logs statements on
                                      the client and basically it seems
                                      it<br>
                                      can not parse the response from
                                      the server :<br>
                                      <br>
                                      I/Web Console( 1386): textStatus:
                                      parsererror at<br>
                                      <a moz-do-not-send="true">file:///android_asset/www/js/index.js:103</a><br>
                                      I/Web Console( 1386): error:
                                      SyntaxError: Unexpected end of
                                      input at<br>
<a class="moz-txt-link-freetext" href="file:///android_asset/www/js/index.js:104">file:///android_asset/www/js/index.js:104</a><br>
                                      <br>
                                      If I do a CURL like this :<br>
                                      curl -v -b cookies.txt -c
                                      cookies.txt -H "Accept:
                                      application/json" -H<br>
                                      "Content-type: application/json"
                                      -X POST -d<br>
'{"phoneNumber":"1234567890","email":"<a moz-do-not-send="true"
                                        href="mailto:newTest@test.com"
                                        target="_blank">newTest@test.com</a>","name":"newTest"}'<br>
                                      <a moz-do-not-send="true"
                                        href="http://agmobile-html5.rhcloud.com/rest/forge/members"
                                        target="_blank">http://agmobile-html5.rhcloud.com/rest/forge/members</a><br>
                                      <br>
                                      I should have pointed to the
                                      sources to the REST endpoint:<br>
                                      <a moz-do-not-send="true"
href="https://github.com/burrsutter/agmobile/blob/master/src/main/java/com/burrsutter/agmobile/rest/MemberEndpoint.java"
                                        target="_blank">https://github.com/burrsutter/agmobile/blob/master/src/main/java/com/burrsutter/agmobile/rest/MemberEndpoint.java</a><br>
                                      This was generated by Forge as I
                                      am too lazy to type up a full CRUD
                                      REST<br>
                                      endpoint myself :-)<br>
                                      <br>
                                      <br>
                                      <br>
                                      I got an correct answer but the
                                      content type is 'text/plain' ,
                                      please<br>
                                      check your rest endpoint to be
                                      sure it's producing json as
                                      output, that<br>
                                      should solve your issue.<br>
                                      It says<br>
                                      @POST<br>
                                      @Consumes("application/json")<br>
                                      <br>
                                      needs a
                                      @Produces("application/json")<br>
                                      <br>
                                      I'm not sure that will help. The
                                      response is a HTTP 201 with a
                                      Location<br>
                                      header.<br>
                                      Is the client expecting an entity
                                      of type application/json in the
                                      response ?<br>
                                      <br>
                                      If yes, then the method should
                                      look like:<br>
                                      <br>
                                      @POST<br>
                                      @Consumes("application/json")<br>
                                      public Response create(MemberDTO
                                      dto)<br>
                                      {<br>
                                      Member entity = dto.fromDTO(null,
                                      em);<br>
                                      em.persist(entity);<br>
                                      return<br>
Response.created(UriBuilder.fromResource(MemberEndpoint.class).path(String.valueOf(entity.getId())).build()).entity(entity).build();<br>
                                      }<br>
                                      <br>
                                      I've added : .entity(entity) in
                                      the above method to populate the
                                      response<br>
                                      with the entity.<br>
                                      <br>
                                      <br>
                                      <br>
                                      <br>
                                      <br>
                                      <br>
                                      <br>
                                      <br>
                                      <br>
                                      <br>
                                      Could you also paste the commands
                                      you used in Forge to scaffold the
                                      REST<br>
                                      endpoints so that we can check
                                      there hasn't been an
                                      incompatibility<br>
                                      introduced ?<br>
                                      I just used the Forge Wizard that
                                      is built into JBDS/Tools<br>
                                      <a moz-do-not-send="true"
                                        href="http://screencast.com/t/QrKkCoFZMUn"
                                        target="_blank">http://screencast.com/t/QrKkCoFZMUn</a><br>
                                      <br>
                                      error.status is 201<br>
                                      error.responseText is blank<br>
                                      <br>
                                      <br>
                                      <br>
                                      <br>
                                      <br>
                                      <br>
                                      <br>
                                      On Sat, Dec 14, 2013 at 6:06 PM,
                                      Burr Sutter &lt;<a
                                        moz-do-not-send="true"
                                        href="mailto:bsutter@redhat.com"
                                        target="_blank">bsutter@redhat.com</a>&gt;
                                      wrote:<br>
                                      I am having a problem with
                                      pipe.save(), likely user error :-)<br>
                                      <br>
                                      For some reason, the POST is
                                      occurring, the save seems to work
                                      but the<br>
                                      error callback is invoked, not the
                                      success method.<br>
                                      <br>
                                      And I am doing all of this in the
                                      context of our tooling which has
                                      some<br>
                                      limitations (auto-closing
                                      console/firebug lite)<br>
                                      <br>
                                      <a moz-do-not-send="true"
                                        href="http://screencast.com/t/gosd7Qnhz"
                                        target="_blank">http://screencast.com/t/gosd7Qnhz</a><br>
                                      <br>
                                      REST endpoint:<br>
                                      <a moz-do-not-send="true"
                                        href="http://agmobile-html5.rhcloud.com/rest/forge/members"
                                        target="_blank">http://agmobile-html5.rhcloud.com/rest/forge/members</a><br>
                                      Use of Forge, with the Member.java
                                      entity to offer full CRUD
                                      capabilities<br>
                                      <br>
                                      Sources:<br>
                                      <a moz-do-not-send="true"
href="https://github.com/burrsutter/AGContacts/blob/master/www/js/index.js"
                                        target="_blank">https://github.com/burrsutter/AGContacts/blob/master/www/js/index.js</a><br>
                                      <br>
                                      <br>
_______________________________________________<br>
                                      aerogear-dev mailing list<br>
                                      <a moz-do-not-send="true"
                                        href="mailto:aerogear-dev@lists.jboss.org"
                                        target="_blank">aerogear-dev@lists.jboss.org</a><br>
                                      <a moz-do-not-send="true"
                                        href="https://lists.jboss.org/mailman/listinfo/aerogear-dev"
                                        target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br>
                                      <br>
_______________________________________________<br>
                                      aerogear-dev mailing list<br>
                                      <a moz-do-not-send="true"
                                        href="mailto:aerogear-dev@lists.jboss.org"
                                        target="_blank">aerogear-dev@lists.jboss.org</a><br>
                                      <a moz-do-not-send="true"
                                        href="https://lists.jboss.org/mailman/listinfo/aerogear-dev"
                                        target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br>
                                      <br>
_______________________________________________<br>
                                      aerogear-dev mailing list<br>
                                      <a moz-do-not-send="true"
                                        href="mailto:aerogear-dev@lists.jboss.org"
                                        target="_blank">aerogear-dev@lists.jboss.org</a><br>
                                      <a moz-do-not-send="true"
                                        href="https://lists.jboss.org/mailman/listinfo/aerogear-dev"
                                        target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br>
                                      <br>
                                      <br>
_______________________________________________<br>
                                      aerogear-dev mailing list<br>
                                      <a moz-do-not-send="true"
                                        href="mailto:aerogear-dev@lists.jboss.org"
                                        target="_blank">aerogear-dev@lists.jboss.org</a><br>
                                      <a moz-do-not-send="true"
                                        href="https://lists.jboss.org/mailman/listinfo/aerogear-dev"
                                        target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br>
                                      <br>
                                      <br>
_______________________________________________<br>
                                      aerogear-dev mailing list<br>
                                      <a moz-do-not-send="true"
                                        href="mailto:aerogear-dev@lists.jboss.org"
                                        target="_blank">aerogear-dev@lists.jboss.org</a><br>
                                      <a moz-do-not-send="true"
                                        href="https://lists.jboss.org/mailman/listinfo/aerogear-dev"
                                        target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br>
                                    </blockquote>
_______________________________________________<br>
                                    forge-dev mailing list<br>
                                    <a moz-do-not-send="true"
                                      href="mailto:forge-dev@lists.jboss.org"
                                      target="_blank">forge-dev@lists.jboss.org</a><br>
                                    <a moz-do-not-send="true"
                                      href="https://lists.jboss.org/mailman/listinfo/forge-dev"
                                      target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a></div>
                                </blockquote>
                              </div>
                              <br>
                            </div>
                          </div>
                        </div>
                      </div>
                      <br>
                      _______________________________________________<br>
                      forge-dev mailing list<br>
                      <a moz-do-not-send="true"
                        href="mailto:forge-dev@lists.jboss.org"
                        target="_blank">forge-dev@lists.jboss.org</a><br>
                      <a moz-do-not-send="true"
                        href="https://lists.jboss.org/mailman/listinfo/forge-dev"
                        target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
                    </blockquote>
                  </div>
                  <br>
                  <br clear="all">
                  <div><br>
                  </div>
                </div>
              </div>
              <span class="HOEnZb"><font color="#888888">-- <br>
                  Lincoln Baxter, III<br>
                  <a moz-do-not-send="true" href="http://ocpsoft.org"
                    target="_blank">http://ocpsoft.org</a><br>
                  "Simpler is better."
                </font></span></div>
            <br>
            _______________________________________________<br>
            forge-dev mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
            <a moz-do-not-send="true"
              href="https://lists.jboss.org/mailman/listinfo/forge-dev"
              target="_blank">https://lists.jboss.org/mailman/listinfo/forge-dev</a><br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
forge-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/forge-dev">https://lists.jboss.org/mailman/listinfo/forge-dev</a></pre>
    </blockquote>
    <br>
  </body>
</html>