Create a user using the API REST

Bonjour

J'ai essayé de créer un “user” en utilisant l'API REST

Voici mes paramètres:

set url="http://localhost:8081/nuxeo/api/v1/user"
set data="{ \"entity-type\": \"NuxeoPrincipal\", \"id\":\"toto\" }"
curl -X POST -H %header% -u %auth% -d %data% %url%

l'erreur montre:

Caused by: javax.ws.rs.WebApplicationException
    at org.nuxeo.ecm.restapi.jaxrs.io.usermanager.NuxeoPrincipalReader.readJson(NuxeoPrincipalReader.java:152)
    at org.nuxeo.ecm.restapi.jaxrs.io.usermanager.NuxeoPrincipalReader.readRequest(NuxeoPrincipalReader.java:100)
    at org.nuxeo.ecm.restapi.jaxrs.io.usermanager.NuxeoPrincipalReader.readFrom(NuxeoPrincipalReader.java:84)
    at org.nuxeo.ecm.restapi.jaxrs.io.usermanager.NuxeoPrincipalReader.readFrom(NuxeoPrincipalReader.java:57)
    at com.sun.jersey.spi.container.ContainerRequest.getEntity(ContainerRequest.java:488)
    at com.sun.jersey.server.impl.model.method.dispatch.EntityParamDispatchProvider$EntityInjectable.getValue(Entit
ParamDispatchProvider.java:123)
    at com.sun.jersey.server.impl.inject.InjectableValuesProvider.getInjectableValues(InjectableValuesProvider.java

46)

J'ai utilisé la doc dans http://doc.nuxeo.com/display/public/NXDOC/Resources+Endpoints

Merci d'avance Christian

0 votes

1 answers

3935 views

ANSWER



en fait j'ai résolu moi-même le problème en corrigeant la syntaxe de mon appel:

set header="Content-Type: application/json"
set auth="Administrator:Administrator"
set url="http://localhost:8081/nuxeo/api/v1/user"
set data="{ \"entity-type\": \"user\", \"id\":\"bbb\", \"properties\":{\"username\":\"aaa\", \"email\":\"aaa@a.b\", \"lastName\":\"bbb\", \"firstName\":\"x\", \"password\":\"bbb\" } }"

curl --trace-ascii log.txt -X POST -H %header% -u %auth% -d %data% %url%

Mon erreur était sur l'entity-type

Christian

0 votes