Hi,

Note that the recommended way to build a RestAPI today is to use the webengine and Jax-RS annotation (with @POST annotation on the method you would program).
you can follow the tutorial of webengine to start whith this techno.


Alain

Le 17 juil. 09 à 16:15, Richard Louapre a écrit :

Daniel,

Can you try req.getEntity().getText()?

On Fri, Jul 17, 2009 at 8:29 AM, Daniel Perez Alvarez <[email protected] > wrote: We are building a Restlet service to create certain documents. We've registered it like this:

<?xml version="1.0"?>
<component name="es.seia.ereg.rest">
<extension target="org.nuxeo.ecm.platform.ui.web.restAPI.service.PluggableRestletService "
point="restlets">

<restletPlugin name="createReg" class="es.seia.ereg.rest.CreateRegRestlet"
    enabled="true" useSeam="true" useConversation="false">
    <urlPatterns>
      <urlPattern>/{repo}/{parentdocid}/createReg</urlPattern>
    </urlPatterns>
  </restletPlugin>

 </extension>
</component>

The problem is we are not able to access POST data, only GET. In Chapter 31 of the Nuxeo book, it recommends using getAttributes() to access URL parameters, and getResourceRef().getQueryAsForm() for GET/ POST parameters. We also tried a static method you use sometimes, getQueryParamValue(), but to no avail.

To sum up, URL parameters and GET data are retrieved correctly, POST isn't.

Our code looks like this:

@Name("createReg")
@Scope(EVENT)
public class CreateRegRestlet extends BaseNuxeoRestlet implements Serializable
{
  @Override
  public void handle(Request req, Response res)
  {
      Method method = req.getMethod();
      log.info(method.getName() + " request");

      Map<String, Object> attrs = req.getAttributes();
      for (Map.Entry<String, Object> attr : attrs.entrySet())
      {
          log.info(attr.getKey() + " => " + attr.getValue());
      }

log.info("xml => " + req.getResourceRef().getQueryAsForm().getFirstValue("xml");

      log.info("xml => " + getQueryParamValue(req, "xml", "no luck"));
  }
}

This HTTP GET request:

GET /nuxeo/restAPI/repo/parent/createReg?xml=test HTTP/1.1
Authorization: Basic YWRtaW46YWRtaW4=
Host: localhost:8080

Prints this:

parentdocid => parent
repo => repo
xml => test
xml => test

While this HTTP POST request:

POST /nuxeo/restAPI/repo/parent/createReg HTTP/1.1
Authorization: Basic YWRtaW46YWRtaW4=
Host: localhost:8080
Content-Length: 11

xml=test

Prints this:

parentdocid => parent
repo => repo
xml =>
xml => no luck


Could anybody shed some light on this matter? It would be greatly appreciated.


Daniel Pérez Álvarez

Technological Solutions
Atos Origin
+34 91 126 7290
C/ Albasanz, 16
28037 Madrid
Spain
------------------------------------------------------------------
This e-mail and the documents attached are confidential and intended
solely for the addressee; it may also be privileged. If you receive
this e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin
group liability cannot be triggered for the message content. Although
the sender endeavours to maintain a computer virus-free network,
the sender does not warrant that this transmission is virus-free and
will not be liable for any damages resulting from any virus transmitted.

Este mensaje y los ficheros adjuntos pueden contener informacion confidencial
destinada solamente a la(s) persona(s) mencionadas anteriormente
pueden estar protegidos por secreto profesional.
Si usted recibe este correo electronico por error, gracias por informar
inmediatamente al remitente y destruir el mensaje.
Al no estar asegurada la integridad de este mensaje sobre la red, Atos Origin no se hace responsable por su contenido. Su contenido no constituye ningun compromiso para el grupo Atos Origin, salvo ratificacion escrita por ambas partes. Aunque se esfuerza al maximo por mantener su red libre de virus, el emisor no puede garantizar nada al respecto y no sera responsable de cualesquiera
danos que puedan resultar de una transmision de virus.
------------------------------------------------------------------

_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm
To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm

_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm
To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm

_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm
To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm

Reply via email to