Issue with REST APIs to create User

Hi,

I am facing this issue while creating a user via REST API, below is my curl script and getting this response

curl -X POST
http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/XWiki/pages/foo/objects
-H ‘Authorization: Basic UmFqYW5LdW1hcjoxMjM0NTY=’
-H ‘Content-Type: application/x-www-form-urlencoded’
-d ‘className=XWiki.XWikiUsers&property%23first_name=Test&property%23last_name=Kumar&property%23password=*******’

Response

{
“code”: 404,
“contactEmail”: null,
“description”: “The server has not found anything matching the request URI”,
“homeRef”: “/”,
“reasonPhrase”: “Not Found”,
“uri”: “http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.5
}

Kind Regards
Rajan

You are using the API to add an object in a page but I guess the page does not exist.

1 Like

@tmortagne, Thanks for your response. I am new to Xwiki and have some doubts. Let me clarify what I want to do and then please suggest/guide me how I can achieve same.
I want to create different wikis under the main wiki and then there will be multiple users with the limited access to the respective wikis. The wikis will be having the pages/comments etc. Now to add this, Do I need to add any page (as mentioned by you in previous reply) ?
I am trying to add the user through the REST API. And the wikis will also be created using REST APIs as well.
Please let me know if I am missing something. Thanks in advance for your help.

Pretty much everything is a wiki page in XWiki. The request example you gave add a user object in the page “XWiki.foo” (which will become the user id) but the object REST API expect the page to already exist when you add a new object (all objects are stored in wiki pages).

1 Like

@tmortagne Thanks for your response!

Create a page is working. Now i am trying to create a wiki via REST API, getting the error message

com.xpn.xwiki.plugin.packaging.PackageException: Error number 0 in 5: Exception in plugin [Package]: Could not find the package definition

And sometimes, I am getting this one:

{
“code”: 500,
“contactEmail”: null,
“description”: “The server encountered an unexpected condition which prevented it from fulfilling the request”,
“homeRef”: “/”,
“reasonPhrase”: “Internal Server Error”,
“uri”: “http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1
}

curl -X POST
http://localhost:8080/xwiki/rest/wikis/xwiki

Please let me know if I am missing something.

@tmortagne Kindly suggest, how can i resolve the above issue

@netzwelt.rajan hello! Have you found out how to do it? I also want to provision users for the subwiki automatically. netzwelt.rajan