From ashtarcommunications@gmail.com Sat Nov 5 08:46:13 2011 From: Ashtar Communications To: xwiki-users@xwiki.org Subject: [xwiki-users] RESTful API to create a new object of custom class? Date: Sat, 05 Nov 2011 01:46:10 -0700 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0588288738042202516==" --===============0588288738042202516== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi, Is it possible to create a new object of a custom class using the RESTful API? The documentation page only lists the following POST method, which doesn't accept a class name: /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/objects[?start=3Doffset= &number=3Dn] I have tried things like the following: curl -u Admin:admin -X POST -H "Content-type: text/plain" -H "Accept: application/xml" -d "@test.xml" http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects/XWiki.= TestClass Where test.xml contains some variation on: This is some text. Curl returns this: Status page

The method specified in the request is not allowed for the resource ident= ifi ed by the request URI

You can get technical details here.
Please continue your visit at our home page.

Simpler syntax without the XML file still fails for me. In fact, I can't seem to even get the basic "create object" method to work, even without the class. For example: curl -u Admin:admin -X POST http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects Just comes back with a "malformed syntax" error. Is there an example anywhere of how to do this? Thank you, Aaron --===============0588288738042202516==-- From mariusdumitru.florea@xwiki.com Mon Nov 7 06:55:42 2011 From: Marius Dumitru Florea To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] RESTful API to create a new object of custom class? Date: Mon, 07 Nov 2011 08:55:34 +0200 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0169027274250815695==" --===============0169027274250815695== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi Aaron, On Sat, Nov 5, 2011 at 10:46 AM, Ashtar Communications wrote: > Hi, > > Is it possible to create a new object of a custom class using the RESTful A= PI? > > The documentation page only lists the following POST method, which > doesn't accept a class name: > /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/objects[?start=3Doffs= et&number=3Dn] True, but the documentation page ( http://platform.xwiki.org/xwiki/bin/view/Features/XWikiRESTfulAPI#HObjectreso= urces ) also says that the supported media types are: * either application/xml (Object element) or * application/x-www-form-urlencoded (a set of property#name=3Dvalue pairs representing properties and a field className) Regarding the first option, I would add the object manually from the wiki (object editor), then export the page as XAR, then look for the "object" tag inside the XML file corresponding to the exported wiki page and use it as POST data for the REST API. Note that the class is specified in the content of the object element so you don't have to specify it in the REST resource URL. Regarding the second option, I would try something like: className=3DXWiki.TestClass&Text=3DThis%20is%20some%20text I think the specified class must exist because otherwise the REST API won't be able to determine the type of the listed properties (e.g. "Text"). Hope this helps, Marius > > I have tried things like the following: > curl -u Admin:admin -X POST -H "Content-type: text/plain" -H "Accept: > application/xml" -d "@test.xml" > http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects/XWik= i.TestClass > > Where test.xml contains some variation on: > > > > > > > > > > > > > > > > > This is some text. > > > > Curl returns this: > > > =C2=A0 Status page > > >

The method specified in the request is not allowed for the resource ide= ntifi > ed by the request URI

You can get technical details 3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.6">here.
> Please continue your visit at our home page. >

> > > > Simpler syntax without the XML file still fails for me. In fact, I > can't seem to even get the basic "create object" method to work, even > without the class. For example: > curl -u Admin:admin -X POST > http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects > > Just comes back with a "malformed syntax" error. > > Is there an example anywhere of how to do this? > > Thank you, > > Aaron > _______________________________________________ > users mailing list > users(a)xwiki.org > http://lists.xwiki.org/mailman/listinfo/users > --===============0169027274250815695==-- From fabio.mancinelli@xwiki.com Mon Nov 7 16:25:56 2011 From: Fabio Mancinelli To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] RESTful API to create a new object of custom class? Date: Mon, 07 Nov 2011 17:25:52 +0100 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1574164011431586017==" --===============1574164011431586017== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi, you were almost there :) Your request has two things that were wrong: 1) A text/plain content type instead of application/xml 2) The URI for POSTing new object is /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/objects (and not /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/objects/{className}) ...And your XML is missing the className element which will tell the REST API what class has to be used. So to sum up, imagine that you want to create on the page Test.Test a new object of the class XWiki.TestClass, supposing that the class has a Text property (like in your example) So you have to do the following: $ curl -u Admin:admin -X POST -H "Content-type: application/xml" -H "Accept: application/xml" -d "@test.xml" http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects where test.xml is: XWiki.TestClass Whatever you want to put here Alternatively you can use the less verbose application/x-www-form-urlencoded format: $ curl -u Admin:admin -X POST -H "Content-type: application/x-www-form-urlencoded" -H "Accept: application/xml" -d "@test.txt" http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/ob= jects where test.txt contains something like: "className=3DXWiki.TestClass&property#Test=3DWhatever+you+want". Or, better, you can use directly curl to specify these parameters using multiple -d switches: $ curl -u Admin:admin -X POST -H "Content-type: application/x-www-form-urlencoded" -H "Accept: application/xml" -d "className=3DXWiki.TestClass" -d "property#Test=3DWhatever you want" http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects The advantage of the second approach is that curl will take care of url-encode your content, while if you send a file you are responsible for this. Now some remarks: 1) In the application/x-www-form-urlencoded format the "property#" is a standard immutable prefix that is used to distinguish attributes referring to properties from the attributes referring to the object. For example if we had "className=3DXYZ&Text=3DFOO" we would have had an ambiguity on className because we couldn't understand if className is a property of the object to be set to XYZ or an attribute that describes the object itself (i.e., its metadata like the className). By having the property# prefix this ambiguity is resolved. 2) The information you get back when you retrieve an object (i.e., all the elements) are useful when clients need to understand the type of data contained in an object (e.g., when they want to display it). They are not necessary when creating an object because the system already has this information. That's why the XML to be sent is smaller. Actually the only information needed is the and a set of elements. 3) How do you know what kind of information you can send with the XML? You can discover it by using the class description URI. If you go to http://localhost:8080/xwiki/rest/wikis/xwiki/classes you will get a list of all the classes defined in the Wiki. By looking at this you will understand what are the properties defined by each class, their types and attributes. In that way you will know what you're allowed to put in the elements of the XML you send. Hope this answers your questions. -Fabio On Sat, Nov 5, 2011 at 9:46 AM, Ashtar Communications wrote: > Hi, > > Is it possible to create a new object of a custom class using the RESTful A= PI? > > The documentation page only lists the following POST method, which > doesn't accept a class name: > /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/objects[?start=3Doffs= et&number=3Dn] > > I have tried things like the following: > curl -u Admin:admin -X POST -H "Content-type: text/plain" -H "Accept: > application/xml" -d "@test.xml" > http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects/XWik= i.TestClass > > Where test.xml contains some variation on: > > > > > > > > > > > > > > > > > This is some text. > > > > Curl returns this: > > > =C2=A0 Status page > > >

The method specified in the request is not allowed for the resource ide= ntifi > ed by the request URI

You can get technical details 3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.6">here.
> Please continue your visit at our home page. >

> > > > Simpler syntax without the XML file still fails for me. In fact, I > can't seem to even get the basic "create object" method to work, even > without the class. For example: > curl -u Admin:admin -X POST > http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects > > Just comes back with a "malformed syntax" error. > > Is there an example anywhere of how to do this? > > Thank you, > > Aaron > _______________________________________________ > users mailing list > users(a)xwiki.org > http://lists.xwiki.org/mailman/listinfo/users > --===============1574164011431586017==-- From ashtarcommunications@gmail.com Tue Nov 8 09:37:03 2011 From: Ashtar Communications To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] RESTful API to create a new object of custom class? Date: Tue, 08 Nov 2011 01:36:59 -0800 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============6610400739923623362==" --===============6610400739923623362== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Thank you both very much! Your suggestions worked perfectly... aaron On Mon, Nov 7, 2011 at 8:25 AM, Fabio Mancinelli wrote: > Hi, > > you were almost there :) > > Your request has two things that were wrong: > > 1) A text/plain content type instead of application/xml > 2) The URI for POSTing new object is > /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/objects (and not > =C2=A0/wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/objects/{classN= ame}) > > ...And your XML is missing the className element which will tell the > REST API what class has to be used. > > So to sum up, imagine that you want to create on the page Test.Test a > new object of the class XWiki.TestClass, supposing that the class has > a Text property (like in your example) > So you have to do the following: > > $ curl -u Admin:admin -X POST -H "Content-type: application/xml" -H > "Accept: application/xml" -d "@test.xml" > http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects > > where test.xml is: > > > =C2=A0XWiki.TestClass > =C2=A0 > =C2=A0 =C2=A0Whatever you want to put here > > > > Alternatively you can use the less verbose > application/x-www-form-urlencoded format: > > $ curl -u Admin:admin -X POST -H "Content-type: > application/x-www-form-urlencoded" -H "Accept: application/xml" -d > "@test.txt" http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/= objects > > where test.txt contains something like: > "className=3DXWiki.TestClass&property#Test=3DWhatever+you+want". > > Or, better, you can use directly curl to specify these parameters > using multiple -d switches: > > $ curl -u Admin:admin -X POST -H "Content-type: > application/x-www-form-urlencoded" -H "Accept: application/xml" -d > "className=3DXWiki.TestClass" -d "property#Test=3DWhatever you want" > http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects > > The advantage of the second approach is that curl will take care of > url-encode your content, while if you send a file you are responsible > for this. > > Now some remarks: > > 1) In the application/x-www-form-urlencoded format the "property#" is > a standard immutable prefix that is used to distinguish attributes > referring to properties from the attributes referring to the object. > For example if we had "className=3DXYZ&Text=3DFOO" we would have had an > ambiguity on className because we couldn't understand if className is > a property of the object to be set to XYZ or an attribute that > describes the object itself (i.e., its metadata like the className). > By having the property# prefix this ambiguity is resolved. > > 2) The information you get back when you retrieve an object (i.e., all > the elements) are useful when clients need to understand > the type of data contained in an object (e.g., when they want to > display it). They are not necessary when creating an object because > the system already has this information. That's why the XML to be sent > is smaller. Actually the only information needed is the > and a set of elements. > > 3) How do you know what kind of information you can send with the XML? > You can discover it by using the class description URI. If you go to > http://localhost:8080/xwiki/rest/wikis/xwiki/classes you will get a > list of all the classes defined in the Wiki. By looking at this you > will understand what are the properties defined by each class, their > types and attributes. In that way you will know what you're allowed to > put in the elements of the XML you send. > > Hope this answers your questions. > > -Fabio > > On Sat, Nov 5, 2011 at 9:46 AM, Ashtar Communications > wrote: >> Hi, >> >> Is it possible to create a new object of a custom class using the RESTful = API? >> >> The documentation page only lists the following POST method, which >> doesn't accept a class name: >> /wikis/{wikiName}/spaces/{spaceName}/pages/{pageName}/objects[?start=3Doff= set&number=3Dn] >> >> I have tried things like the following: >> curl -u Admin:admin -X POST -H "Content-type: text/plain" -H "Accept: >> application/xml" -d "@test.xml" >> http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects/XWi= ki.TestClass >> >> Where test.xml contains some variation on: >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> This is some text. >> >> >> >> Curl returns this: >> >> >> =C2=A0 Status page >> >> >>

The method specified in the request is not allowed for the resource id= entifi >> ed by the request URI

You can get technical details > 3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.6">here.
>> Please continue your visit at our home page. >>

>> >> >> >> Simpler syntax without the XML file still fails for me. In fact, I >> can't seem to even get the basic "create object" method to work, even >> without the class. For example: >> curl -u Admin:admin -X POST >> http://localhost/xwiki/rest/wikis/xwiki/spaces/Test/pages/Test/objects >> >> Just comes back with a "malformed syntax" error. >> >> Is there an example anywhere of how to do this? >> >> Thank you, >> >> Aaron >> _______________________________________________ >> users mailing list >> users(a)xwiki.org >> http://lists.xwiki.org/mailman/listinfo/users >> > _______________________________________________ > users mailing list > users(a)xwiki.org > http://lists.xwiki.org/mailman/listinfo/users > --===============6610400739923623362==-- From pgregoire@eddyfi.com Tue Mar 1 14:42:25 2016 From: pgregoire To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] RESTful API to create a new object of custom class? Date: Tue, 01 Mar 2016 06:42:22 -0700 Message-ID: <1456839742756-7598184.post@n2.nabble.com> In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3169285411978469111==" --===============3169285411978469111== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hello, I read through this thread, and being a newbie to XWiki, I do understand the cURL syntax explained here, but it's the location of wikis/pages/classes I'm unsure about. I created a custom class of which I'm able to instanciate objects, and list them using a LiveTable. The className I'm using in the LiveTable options is "Development.Resources.Version Information.VersionInformationClass". New VersionInformationClass instances I'm creating wind up in the tree under [Home Symbol] / Software Development / Resources / Version Information. I'd like to create new instances of that class using cURL. I think the following syntax would look about right: "C:\Program Files\cURL\bin\curl.exe" -u AdminUser:AdminPassword -X POST -H "Content-type: application/x-www-form-urlencoded" -H "Accept: application/xml" -d "className=3DDevelopment.Resources.Version Information.VersionInformationClass" -d "property#Name=3DTestABCD" http://localhost/xwiki/rest/wikis/xwiki/spaces/Development/pages/VersionInfor= mation/objects Now I have many more properties than just Name, but for testing I figured I'd start just with that one. The className I'm pretty sure about since this is exactly what I'm successfully using in my LiveTable. I think the problem is my URI. I'm not sure what the wiki, space and class should be in that context. I get the following output: Status page

Not Found

The server has not found anything matching the request URI

You can get technical details here .
Please continue your visit at our home page .

Can someone help me figure out the correct URI? Thank you Phil -- View this message in context: http://xwiki.475771.n2.nabble.com/RESTful-API-t= o-create-a-new-object-of-custom-class-tp6965384p7598184.html Sent from the XWiki- Users mailing list archive at Nabble.com. --===============3169285411978469111==-- From jean.simard@xwiki.com Tue Mar 1 14:57:46 2016 From: Jean SIMARD To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] RESTful API to create a new object of custom class? Date: Tue, 01 Mar 2016 14:57:43 +0100 Message-ID: <56D59FD7.3060005@xwiki.com> In-Reply-To: <1456839742756-7598184.post@n2.nabble.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2830991706123629110==" --===============2830991706123629110== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi Phil, I'm not sure exactly what's wrong with what you're doing but here is two thought that may help you. 1) First, you say that "New VersionInformationClass instances I'm creating wind up in the tree under [Home Symbol] / Software Development / Resources / Version Information." so I would expect a URI of the following form http://localhost/xwiki/rest/wikis/xwiki/spaces/Software Development/spaces/Resources/spaces/Version Information/pages/VersionInformation/objects 2) I see that you put spaces (the character ' ') in some of the spaces name (wiki's nested spaces). It should be possible to make it work with spaces (character) but I'm not sure about the syntax in this case (maybe a '+' to replace ' ', maybe something else). You may want to test without first to see if the problem come from this character or not? Hope this helps, Sincerely, On 01/03/2016 14:42, pgregoire wrote: > Hello, > I read through this thread, and being a newbie to XWiki, I do understand the > cURL syntax explained here, but it's the location of wikis/pages/classes I'm > unsure about. >=20 > I created a custom class of which I'm able to instanciate objects, and list > them using a LiveTable. > The className I'm using in the LiveTable options is > "Development.Resources.Version Information.VersionInformationClass". > New VersionInformationClass instances I'm creating wind up in the tree under > [Home Symbol] / Software Development / Resources / Version Information. >=20 > I'd like to create new instances of that class using cURL. > I think the following syntax would look about right: >=20 > "C:\Program Files\cURL\bin\curl.exe" -u AdminUser:AdminPassword -X POST -H > "Content-type: application/x-www-form-urlencoded" -H "Accept: > application/xml" -d "className=3DDevelopment.Resources.Version > Information.VersionInformationClass" -d "property#Name=3DTestABCD" > http://localhost/xwiki/rest/wikis/xwiki/spaces/Development/pages/VersionInf= ormation/objects >=20 > Now I have many more properties than just Name, but for testing I figured > I'd start just with that one. > The className I'm pretty sure about since this is exactly what I'm > successfully using in my LiveTable. > I think the problem is my URI. I'm not sure what the wiki, space and class > should be in that context. >=20 > I get the following output: > > > Status page > > >

Not Found<= /p> >

The server has not found anything matching the request URI

>

You can get technical details here > .
> Please continue your visit at our home page . >

> > >=20 > Can someone help me figure out the correct URI? >=20 > Thank you > Phil >=20 >=20 >=20 >=20 > -- > View this message in context: http://xwiki.475771.n2.nabble.com/RESTful-API= -to-create-a-new-object-of-custom-class-tp6965384p7598184.html > Sent from the XWiki- Users mailing list archive at Nabble.com. > _______________________________________________ > users mailing list > users(a)xwiki.org > http://lists.xwiki.org/mailman/listinfo/users >=20 --=20 Jean Simard jean.simard(a)xwiki.com Research engineer at XWiki SAS http://www.xwiki.com Committer on the XWiki.org project http://www.xwiki.org --===============2830991706123629110==-- From pgregoire@eddyfi.com Tue Mar 1 17:17:46 2016 From: pgregoire To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] RESTful API to create a new object of custom class? Date: Tue, 01 Mar 2016 09:17:43 -0700 Message-ID: <1456849063916-7598216.post@n2.nabble.com> In-Reply-To: <56D59FD7.3060005@xwiki.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1991232212536880164==" --===============1991232212536880164== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Thank you, so basically everything that has children is considered a space? I tried the two following syntaxes: -X POST -H "Content-type: application/x-www-form-urlencoded" - H "Accept: application/xml" -d "className=3DDevelopment.Resources.Version Information.VersionInformationClass" -d "property#Name=3DTestABCD" htt p://localhost/xwiki/rest/wikis/xwiki/spaces/Software+Development/spaces/Resou= rces/*pages*/Version+Information/objects I get this reply:

The server has not found anything matching the request URI

With the following: http://localhost/xwiki/rest/wikis/xwiki/spaces/Software+Development/spaces/Re= sources/*spaces*/Version+Information/objects I get this:

The method specified in the request is not allowed for the resource identified by the request URI

Which would indicate that it might be the correct URI, but for some reason the request is not allowed? -- View this message in context: http://xwiki.475771.n2.nabble.com/RESTful-API-t= o-create-a-new-object-of-custom-class-tp6965384p7598216.html Sent from the XWiki- Users mailing list archive at Nabble.com. --===============1991232212536880164==-- From jean.simard@xwiki.com Tue Mar 1 17:31:26 2016 From: Jean SIMARD To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] RESTful API to create a new object of custom class? Date: Tue, 01 Mar 2016 17:31:24 +0100 Message-ID: <56D5C3DC.7060509@xwiki.com> In-Reply-To: <1456849063916-7598216.post@n2.nabble.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1531628247509715889==" --===============1531628247509715889== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable It seems that Version+Information is a space, not a (terminal) page. And indeed, you'll not be able to add objects to a space. Nested spaces is a new functionality from version 7.x. You may want to read about "Nested Spaces" in order to understand more what's a page and what's a space in the this context. In your case, you may try to use the following URI http://localhost/xwiki/rest/wikis/xwiki/spaces/Software+Development/spaces/Re= sources/spaces/Version+Information/pages/WebHome/objects This WebHome should be here (I hope I'm not saying wrong things) for retro-compatibility reasons. In any case, I'm not mastering Nested Spaces so documentation (or another community member more aware of the topic?) will say less crap than me ;-) Sincerely, On 01/03/2016 17:17, pgregoire wrote: > Thank you, > so basically everything that has children is considered a space? >=20 > I tried the two following syntaxes: >=20 > -X POST -H "Content-type: application/x-www-form-urlencoded" - > H "Accept: application/xml" -d "className=3DDevelopment.Resources.Version > Information.VersionInformationClass" -d "property#Name=3DTestABCD" htt > p://localhost/xwiki/rest/wikis/xwiki/spaces/Software+Development/spaces/Res= ources/*pages*/Version+Information/objects >=20 > I get this reply: >

The server has not found anything matching the request URI

>=20 > With the following: > http://localhost/xwiki/rest/wikis/xwiki/spaces/Software+Development/spaces/= Resources/*spaces*/Version+Information/objects >=20 > I get this: >

The method specified in the request is not allowed for the resource > identified by the request URI

>=20 > Which would indicate that it might be the correct URI, but for some reason > the request is not allowed? >=20 >=20 >=20 > -- > View this message in context: http://xwiki.475771.n2.nabble.com/RESTful-API= -to-create-a-new-object-of-custom-class-tp6965384p7598216.html > Sent from the XWiki- Users mailing list archive at Nabble.com. > _______________________________________________ > users mailing list > users(a)xwiki.org > http://lists.xwiki.org/mailman/listinfo/users >=20 --=20 Jean Simard jean.simard(a)xwiki.com Research engineer at XWiki SAS http://www.xwiki.com Committer on the XWiki.org project http://www.xwiki.org --===============1531628247509715889==-- From pgregoire@eddyfi.com Tue Mar 1 17:44:42 2016 From: pgregoire To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] RESTful API to create a new object of custom class? Date: Tue, 01 Mar 2016 09:44:39 -0700 Message-ID: <1456850679735-7598222.post@n2.nabble.com> In-Reply-To: <56D5C3DC.7060509@xwiki.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============5079546711015499023==" --===============5079546711015499023== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Ok I think we're on to something now... The actual name of the space is "Development". "Software Development" is just the pretty name. I entered the page as WebHome. http://srvwiki:8080/xwiki/rest/wikis/xwiki/spaces/Development/spaces/Resource= s/spaces/Version+Information/pages/WebHome/objects Just ran this and I managed to create the object. It just overwrote the Version Information page instead of creating the new object under it. Getting there! -- View this message in context: http://xwiki.475771.n2.nabble.com/RESTful-API-t= o-create-a-new-object-of-custom-class-tp6965384p7598222.html Sent from the XWiki- Users mailing list archive at Nabble.com. --===============5079546711015499023==-- From pgregoire@eddyfi.com Wed Mar 2 16:11:05 2016 From: pgregoire To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] RESTful API to create a new object of custom class? Date: Wed, 02 Mar 2016 08:11:01 -0700 Message-ID: <1456931461586-7598260.post@n2.nabble.com> In-Reply-To: <1456850679735-7598222.post@n2.nabble.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4521812775970872766==" --===============4521812775970872766== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable I'm sorry, I think I still need a little help here... So, I managed to get my object created.=20 To give you an idea, I have a page (at Development.Resources.Version Information.WebHome) where I have a LiveTable that shows all my VersionInformation objects. When I create these objects, they wind up in the hierarchy under the Version Information node. The only way I was able to run the cURL command properly was with this command line: "C:\Program Files\cURL\bin\curl.exe" -u AdminUser:AdminPwd -X POST -H "Content-type: application/x-www-form-urlencoded" -H "Accept: application/xml" -d "className=3DXWiki.Development.Resources.Version Information.VersionInformationClass" -d "property#Name=3DTestABCD" http://localhost/xwiki/rest/wikis/xwiki/spaces/Development/spaces/VersionInfo= rmation/pages/WebHome/objects But doing this overwrites the Development.Resources.Version Information.WebHome with the newly created object. Now, it seems that the URI must end with a page, but it is my understanding the a page can't have children - so how do I create VersionInformation class instances under a certain node? Thanks again for the help. -- View this message in context: http://xwiki.475771.n2.nabble.com/RESTful-API-t= o-create-a-new-object-of-custom-class-tp6965384p7598260.html Sent from the XWiki- Users mailing list archive at Nabble.com. --===============4521812775970872766==-- From pgregoire@eddyfi.com Thu Mar 3 18:01:53 2016 From: pgregoire To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] RESTful API to create a new object of custom class? Date: Thu, 03 Mar 2016 10:01:50 -0700 Message-ID: <1457024510725-7598295.post@n2.nabble.com> In-Reply-To: <1456931461586-7598260.post@n2.nabble.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============7869671031516675672==" --===============7869671031516675672== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Ok an update here... With the following syntax: "C:\Program Files\cURL\bin\curl.exe" -u admin:admin -X *POST *-H "Content-type: application/x-www-form-urlencoded" -H "Accept: application/xml" -d "className=3DXWiki.Development.Resources.Version Information.VersionInformationClass" -d "property#Name=3DTestABCD" -d "property#Product=3D4.0" http://localhost/xwiki/rest/wikis/xwiki/spaces/Development/spaces/Resources/s= paces/Version+Information/pages/*WebHome/objects* it seems that some object does created - if I go to the Version Information webhome, click edit and select Objects, I see the following: XWiki.Development.Resources.Version Information.VersionInformationClass Development.Resources.Version Information.VersionInformationClass 0 And instances get added each time I run it again a new instance gets added (0, 1, etc.). It seems there's nothing I can do with these instances except delete them. I don't see them in the tree either. Something else I tried is the following: "C:\Program Files\cURL\bin\curl.exe" -u admin:admin -X *PUT *-H "Content-type: application/x-www-form-urlencoded" -H "Accept: application/xml" -d "className=3DXWiki.Development.Resources.Version Information.VersionInformationClass" -d "property#Name=3DTestABCD" -d "property#Product=3D4.0" http://localhost/xwiki/rest/wikis/xwiki/spaces/Development/spaces/Resources/s= paces/Version+Information/*pages/TestABCD* In this case, a new page called TestABCD appears in the hierarchy under Version Information. But it's a regular page, not a Version Information one like I can create with the template. Could my issue be that my object creation does not include every property of the class? Or am I not understanding the concept the class objects properly? What I'm looking for is to wind up with a page that looks the same as when I create a new page using my Version Information template. -- View this message in context: http://xwiki.475771.n2.nabble.com/RESTful-API-t= o-create-a-new-object-of-custom-class-tp6965384p7598295.html Sent from the XWiki- Users mailing list archive at Nabble.com. --===============7869671031516675672==-- From pgregoire@eddyfi.com Fri Mar 4 15:11:21 2016 From: pgregoire To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] RESTful API to create a new object of custom class? Date: Fri, 04 Mar 2016 07:11:18 -0700 Message-ID: <1457100678954-7598319.post@n2.nabble.com> In-Reply-To: <1457024510725-7598295.post@n2.nabble.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8845849707828388244==" --===============8845849707828388244== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Finally made it! So - first of all I messed up my class name while trying stuff out, I didn't need the XWiki. prefix in there. Second, I first create the page with a PUT command, then I make it into an instance of my class (or rather create an object of that class under it and somehow it does the math) with a POST. So I have the following: "C:\Program Files\cURL\bin\curl.exe" -u admin:admin -X PUT ^ -H "Content-type: application/x-www-form-urlencoded" -H "Accept: application/xml" ^ http://localhost/xwiki/rest/wikis/xwiki/spaces/Development/spaces/Resources/s= paces/Version+Information/pages/TestABCD =20 "C:\Program Files\cURL\bin\curl.exe" -u admin:admin -X POST ^ -H "Content-type: application/x-www-form-urlencoded" -H "Accept: application/xml" ^ -d "className=3DDevelopment.Resources.Version Information.VersionInformationClass" ^ -d "property#Name=3DTestABCD" ^ http://localhost/xwiki/rest/wikis/xwiki/spaces/Development/spaces/Resources/s= paces/Version+Information/pages/TestABCD/objects -- View this message in context: http://xwiki.475771.n2.nabble.com/RESTful-API-t= o-create-a-new-object-of-custom-class-tp6965384p7598319.html Sent from the XWiki- Users mailing list archive at Nabble.com. --===============8845849707828388244==-- From vincent@massol.net Fri Mar 4 15:56:29 2016 From: vincent@massol.net To: xwiki-users@xwiki.org Subject: Re: [xwiki-users] RESTful API to create a new object of custom class? Date: Fri, 04 Mar 2016 15:56:26 +0100 Message-ID: In-Reply-To: <1457100678954-7598319.post@n2.nabble.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8577795205087336562==" --===============8577795205087336562== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable =C2=A0 On 4 Mar 2016 at 15:11:24, pgregoire (pgregoire(a)eddyfi.com(mailto:pgregoire= (a)eddyfi.com)) wrote: > Finally made it! Cool, glad you succeeded! And thanks for posting your solution, this could he= lp others. Thanks -Vincent > So - first of all I messed up my class name while trying stuff out, I didn't > need the XWiki. prefix in there. > Second, I first create the page with a PUT command, then I make it into an > instance of my class (or rather create an object of that class under it and > somehow it does the math) with a POST. > =20 > So I have the following: > =20 > "C:\Program Files\cURL\bin\curl.exe" -u admin:admin -X PUT ^ > -H "Content-type: application/x-www-form-urlencoded" -H "Accept: > application/xml" ^ > http://localhost/xwiki/rest/wikis/xwiki/spaces/Development/spaces/Resources= /spaces/Version+Information/pages/TestABCD > =20 > "C:\Program Files\cURL\bin\curl.exe" -u admin:admin -X POST ^ > -H "Content-type: application/x-www-form-urlencoded" -H "Accept: > application/xml" ^ > -d "className=3DDevelopment.Resources.Version > Information.VersionInformationClass" ^ > -d "property#Name=3DTestABCD" ^ > http://localhost/xwiki/rest/wikis/xwiki/spaces/Development/spaces/Resources= /spaces/Version+Information/pages/TestABCD/objects > =20 > =20 > =20 --===============8577795205087336562==--