Re: [xwiki-users] How to add a page with contents in xwiki through Rest api???
Hi. See below ----- "xManish" <[email protected]> wrote:
Jerome Velociter wrote:
Hi Nithya, Manish
Have you checked
http://platform.xwiki.org/xwiki/bin/view/Features/XWikiRESTfulAPI#HPageresou...
?
In particular :
/wikis/{wikiName}/spaces/{spaceName}/pages/{pageName} HTTP Method: PUT * Accepted Media types: o application/xml (Page element) o text/plain (Only page content) o application/x-www-form-urlencoded (allowed field names: title, parent, content)
Is something not clear about it ? Not working ?
Thanks, Jerome
Hi Jerome, Thanks for the reply. I was able to create the page afterwards. Sorry for the impatience :)
Sorry if my message felt harsh, that was not the intend :)
However, today I am into different but similiar situation. I need to create users in XWiki through REST Api. Is it possible? How to do it?
Currently, I'm not sure you can perform this as an atomic operation. Unless maybe your wiki runs with the implicit XWikiAllGroup setting (see http://jira.xwiki.org/jira/browse/XWIKI-2116 ) What you have to do is then use the object REST api ( http://platform.xwiki.org/xwiki/bin/view/Features/XWikiRESTfulAPI#HObjectres... ), creating a page with an object of class XWiki.XWikiUsers If you don't have the implicit XWikiAllGroup then you need to add an object of class XWiki.XWikiGroups with the created user as member, to XWiki.XWikiAllGroup document. I agree an API to directly hit and create users, under /wikis/{wikiName}/users would be nice. Regards, Jerome.
Thanks, Manish -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-add-a-page-with-contents-in-xwiki-t... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
I might really have to apologize to the main creator of this thread for using the thread. Jerome, I'll start a new thread on this topic. "Adding user through Rest Api". Would you please join me there? -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-add-a-page-with-contents-in-xwiki-t... Sent from the XWiki- Users mailing list archive at Nabble.com.
Hi Jerome, Ya of course having /wikis/{wikiName}/users would have been nice. :) But coming to reality, I still have the problem creating user. Here is the code on how I created the wiki page. Can you advise me how to create the wiki user in the similiear manner? public void myAddMethod() { final String CONTENT = "Content 101"; final String TITLE = "Title 101"; final String PARENT = "Private.WebHome"; ObjectFactory objectFactory = new ObjectFactory(); Page page = objectFactory.createPage(); page.setContent(CONTENT); page.setTitle(TITLE); page.setParent(PARENT); HttpClient httpClient = new HttpClient(); httpClient.getState().setCredentials(AuthScope.ANY, new UsernamePasswordCredentials("admin", "admin")); httpClient.getParams().setAuthenticationPreemptive(true); JAXBContext context; try { context = JAXBContext.newInstance("org.xwiki.rest.model.jaxb"); Marshaller marshaller = context.createMarshaller(); Unmarshaller unmarshaller = context.createUnmarshaller(); PutMethod putMethod = new PutMethod("http://localhost:8080/xwiki/rest/wikis/xwiki/spaces/Private/pages/NewPage01"); putMethod.addRequestHeader("Accept", MediaType.APPLICATION_XML.toString()); StringWriter writer = new StringWriter(); marshaller.marshal(page, writer); RequestEntity entity; entity = new StringRequestEntity(writer.toString(), MediaType.APPLICATION_XML.toString(), "UTF-8"); putMethod.setRequestEntity(entity); httpClient.executeMethod(putMethod); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (HttpException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-add-a-page-with-contents-in-xwiki-t... Sent from the XWiki- Users mailing list archive at Nabble.com.
I think I will have to apologize the original creator of this thread for using it to discuss my issue. Jerome, could you please join me in the another thread that I've created for this issue. Its 'Create User in XWiki from REST Api' under XWiki-Dev. THankyou, manish -- View this message in context: http://xwiki.475771.n2.nabble.com/How-to-add-a-page-with-contents-in-xwiki-t... Sent from the XWiki- Users mailing list archive at Nabble.com.
participants (2)
-
Jerome Velociter -
xManish