<div dir="ltr">Either is typical, but I think that most &quot;pure&quot; restifarians would favor the 201.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 16, 2013 at 5:41 PM, Burr Sutter <span dir="ltr">&lt;<a 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&#39;d or to simply respond with a basic acknowledgement (http 201)?<div>
<div class="h5"><div><br></div><div><br><div><div>On Dec 16, 2013, at 4:25 PM, Vineet Reynolds Pereira &lt;<a 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: &quot;Burr Sutter&quot; &lt;<a href="mailto:bsutter@redhat.com" target="_blank">bsutter@redhat.com</a>&gt;<br>To: &quot;AeroGear Developer Mailing List&quot; &lt;<a 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> </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 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: &quot;Lucas Holmquist&quot; &lt; <a href="mailto:lholmqui@redhat.com" target="_blank">lholmqui@redhat.com</a> &gt;<br>To: &quot;AeroGear Developer Mailing List&quot; &lt; <a href="mailto:aerogear-dev@lists.jboss.org" target="_blank">aerogear-dev@lists.jboss.org</a> &gt;<br>
Cc: &quot;Vineet Reynolds Pereira&quot; &lt; <a 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 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 href="mailto:scm.blanc@gmail.com" target="_blank">scm.blanc@gmail.com</a> &gt; wrote:<br><br><br><br>Burr,<br>I&#39;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>file:///android_asset/www/js/index.js:103</a><br>I/Web Console( 1386): error: SyntaxError: Unexpected end of input at<br>
file:///android_asset/www/js/index.js:104<br><br>If I do a CURL like this :<br>curl -v -b cookies.txt -c cookies.txt -H &quot;Accept: application/json&quot; -H<br>&quot;Content-type: application/json&quot; -X POST -d<br>&#39;{&quot;phoneNumber&quot;:&quot;1234567890&quot;,&quot;email&quot;:&quot;<a href="mailto:newTest@test.com" target="_blank">newTest@test.com</a>&quot;,&quot;name&quot;:&quot;newTest&quot;}&#39;<br>
<a 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 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 &#39;text/plain&#39; , please<br>check your rest endpoint to be sure it&#39;s producing json as output, that<br>
should solve your issue.<br>It says<br>@POST<br>@Consumes(&quot;application/json&quot;)<br><br>needs a @Produces(&quot;application/json&quot;)<br><br>I&#39;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(&quot;application/json&quot;)<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&#39;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&#39;t been an incompatibility<br>introduced ?<br>I just used the Forge Wizard that is built into JBDS/Tools<br><a 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 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 href="http://screencast.com/t/gosd7Qnhz" target="_blank">http://screencast.com/t/gosd7Qnhz</a><br><br>REST endpoint:<br><a 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 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 href="mailto:aerogear-dev@lists.jboss.org" target="_blank">aerogear-dev@lists.jboss.org</a><br><a 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 href="mailto:aerogear-dev@lists.jboss.org" target="_blank">aerogear-dev@lists.jboss.org</a><br><a 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 href="mailto:aerogear-dev@lists.jboss.org" target="_blank">aerogear-dev@lists.jboss.org</a><br><a 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 href="mailto:aerogear-dev@lists.jboss.org" target="_blank">aerogear-dev@lists.jboss.org</a><br><a 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 href="mailto:aerogear-dev@lists.jboss.org" target="_blank">aerogear-dev@lists.jboss.org</a><br><a 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 href="mailto:forge-dev@lists.jboss.org" target="_blank">forge-dev@lists.jboss.org</a><br><a 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 href="mailto:forge-dev@lists.jboss.org">forge-dev@lists.jboss.org</a><br>
<a 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>-- <br>Lincoln Baxter, III<br><a href="http://ocpsoft.org" target="_blank">http://ocpsoft.org</a><br>
&quot;Simpler is better.&quot;
</div>