You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@syncope.apache.org by Craig Martin <cr...@gmail.com> on 2018/09/06 17:35:25 UTC

Create User Via REST

Hi,

I am attempting to create a user via the REST Endpoint and I am getting an
error.   I tried to take the curl generated from the swagger specs but that
didn't seem to work either.  What am I doing wrong?  Seems that it doesn't
like the structure of my body.  Any help would be appreciated.

Curl
curl -v -X POST "http://syncope:8080/syncope/rest/users?storePassword=true"
-H "accept: application/json" -H "Prefer: return-content" -H
"X-Syncope-Null-Priority-Async: true" -H "X-Syncope-Domain: Master" -H
"Content-Type: application/json" -d
{"@class":"org.apache.syncope.common.lib.to.UserTO","realm":"/","username":"testEmail","password":"password","type":"USER"}

Response:
Warning: Couldn't read data from file
Warning: "class:org.apache.syncope.common.lib.to.UserTO", this makes an
empty
Warning: POST.
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 10.43.254.215...
* TCP_NODELAY set
* Connected to syncope (10.43.254.215) port 8080 (#0)
> POST /syncope/rest/users?storePassword=true HTTP/1.1
> Host: syncope:8080
> User-Agent: curl/7.58.0
> accept: application/json
> Prefer: return-content
> X-Syncope-Null-Priority-Async: true
> X-Syncope-Domain: Master
> Content-Type: application/json
> Content-Length: 0
>
< HTTP/1.1 400
< X-Application-Error-Code: RESTValidation
< X-Application-Error-Info: RESTValidation:ConstraintViolationException:
< Date: Thu, 06 Sep 2018 17:30:26 GMT
< X-Syncope-Domain: Master
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Connection: close
<
* Closing connection 0
{"status":400,"type":"RESTValidation","elements":["ConstraintViolationException:
"]}Note: Unnecessary use of -X or --request, POST is already inferred.
* Bad URL
* Closing connection -1
curl: (3) Bad URL
Note: Unnecessary use of -X or --request, POST is already inferred.
* Rebuilt URL to: username:testEmail/
* Port number ended with 't'
* Closing connection -1
curl: (3) Port number ended with 't'
Note: Unnecessary use of -X or --request, POST is already inferred.
* Rebuilt URL to: password:password/
* Port number ended with 'p'
* Closing connection -1
curl: (3) Port number ended with 'p'
Note: Unnecessary use of -X or --request, POST is already inferred.
* Rebuilt URL to: type:USER/
* Port number ended with 'U'
* Closing connection -1
curl: (3) Port number ended with 'U'

Re: Create User Via REST

Posted by Craig Martin <cr...@gmail.com>.
Was missing the single quote around the body.   Setting it up like this
worked....

curl -v POST "http://syncope:8080/syncope/rest/users?storePassword=true" -H
"accept: application/json" -H "Prefer: return-content" -H
"X-Syncope-Null-Priority-Async: true" -H "X-Syncope-Domain: Master" -H
"Content-Type: application/json" -H 'Authorization: Basic <BASICAUTH>' -d
'{"@class":"org.apache.syncope.common.lib.to.UserTO","realm":"/","username":"testEmail","password":"password","type":"USER"}'

On Thu, Sep 6, 2018 at 11:35 AM Craig Martin <cr...@gmail.com> wrote:

> Hi,
>
> I am attempting to create a user via the REST Endpoint and I am getting an
> error.   I tried to take the curl generated from the swagger specs but that
> didn't seem to work either.  What am I doing wrong?  Seems that it doesn't
> like the structure of my body.  Any help would be appreciated.
>
> Curl
> curl -v -X POST "http://syncope:8080/syncope/rest/users?storePassword=true"
> -H "accept: application/json" -H "Prefer: return-content" -H
> "X-Syncope-Null-Priority-Async: true" -H "X-Syncope-Domain: Master" -H
> "Content-Type: application/json" -d
> {"@class":"org.apache.syncope.common.lib.to.UserTO","realm":"/","username":"testEmail","password":"password","type":"USER"}
>
> Response:
> Warning: Couldn't read data from file
> Warning: "class:org.apache.syncope.common.lib.to.UserTO", this makes an
> empty
> Warning: POST.
> Note: Unnecessary use of -X or --request, POST is already inferred.
> *   Trying 10.43.254.215...
> * TCP_NODELAY set
> * Connected to syncope (10.43.254.215) port 8080 (#0)
> > POST /syncope/rest/users?storePassword=true HTTP/1.1
> > Host: syncope:8080
> > User-Agent: curl/7.58.0
> > accept: application/json
> > Prefer: return-content
> > X-Syncope-Null-Priority-Async: true
> > X-Syncope-Domain: Master
> > Content-Type: application/json
> > Content-Length: 0
> >
> < HTTP/1.1 400
> < X-Application-Error-Code: RESTValidation
> < X-Application-Error-Info: RESTValidation:ConstraintViolationException:
> < Date: Thu, 06 Sep 2018 17:30:26 GMT
> < X-Syncope-Domain: Master
> < Content-Type: application/json;charset=UTF-8
> < Transfer-Encoding: chunked
> < Connection: close
> <
> * Closing connection 0
> {"status":400,"type":"RESTValidation","elements":["ConstraintViolationException:
> "]}Note: Unnecessary use of -X or --request, POST is already inferred.
> * Bad URL
> * Closing connection -1
> curl: (3) Bad URL
> Note: Unnecessary use of -X or --request, POST is already inferred.
> * Rebuilt URL to: username:testEmail/
> * Port number ended with 't'
> * Closing connection -1
> curl: (3) Port number ended with 't'
> Note: Unnecessary use of -X or --request, POST is already inferred.
> * Rebuilt URL to: password:password/
> * Port number ended with 'p'
> * Closing connection -1
> curl: (3) Port number ended with 'p'
> Note: Unnecessary use of -X or --request, POST is already inferred.
> * Rebuilt URL to: type:USER/
> * Port number ended with 'U'
> * Closing connection -1
> curl: (3) Port number ended with 'U'
>
>
>
>