Changes for page REST API

Last modified by Thomas Mortagne on 2024/03/12

<
From version < 84.1 >
edited by Thomas Mortagne
on 2021/06/24
To version < 87.1 >
edited by Ludovic Dubost
on 2021/06/24
>
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.ThomasMortagne
1 +XWiki.ludovic
Content
... ... @@ -970,12 +970,6 @@
970 970  
971 971  This API is designed to be a REST clone of the JobExecutor Java API (the only real difference right now being way to deal with asynchronous jobs) documented on http://extensions.xwiki.org/xwiki/bin/view/Extension/Job+Module#HUseanexistingjob so the concepts (job type, job request) are the same and the exact information to put in the job request depends on the job you want to run and are usually documented in the extension this job is coming from (extension module, refactoring, etc.). There is JAXB objects provided for the Java side to help generate proper HTTP request but for pure HTTP use case it usually helps to ask for the status of an existing job to have an hint of how the XML/JSON should look like (see [[jobstatus section>>#H2Fjobstatus2F7BjobId7D]]).
972 972  
973 -Since 9.2RC1 jobs started trough the REST API automatically get their runtime context injected with the following REST HTTP request context properties:
974 -
975 -* current wiki
976 -* current user
977 -* request URL and parameters
978 -
979 979  * **HTTP Method:** PUT
980 980  ** **Input:**
981 981  *** Media Types: ##application/xml## or ##application/json##
... ... @@ -989,6 +989,20 @@
989 989  *** 401: If the user is not authorized (i.e. doesn't have Programming Rights)
990 990  *** 500: Failing jobs with ##async=false## return an error 500 (Since 9.7RC1)
991 991  
986 +Jobs started through the REST API automatically get their runtime context injected with the following REST HTTP request context properties:
987 +
988 +* current wiki
989 +* current user
990 +* request URL and parameters
991 +
992 +=== Example of Extension Manager installJob ===
993 +
994 +Using the attach:jobrequest.xml you can use a request like the following one to ask for the installation of an extension (in this example the XWiki OIDC module version 1.28):
995 +
996 +{{code language="none"}}
997 +curl -i --user "Admin:admin" -X PUT -H "Content-Type: text/xml" "http://localhost:8080/xwiki/rest/jobs?jobType=install&async=false" --upload-file installjobrequest.xml
998 +{{/code}}
999 +
992 992  == Localization resources ==
993 993  
994 994  For more details see the [[Localization Module documentation>>extensions:Extension.Localization.WebHome]].
installjobrequest.xml
Author
... ... @@ -1,0 +1,1 @@
1 +XWiki.ludovic
Size
... ... @@ -1,0 +1,1 @@
1 +1.4 KB
Content
... ... @@ -1,0 +1,47 @@
1 +<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2 +<jobRequest xmlns="http://www.xwiki.org">
3 + <id>
4 + <element>extension</element>
5 + <element>provision</element>
6 + <element>796fb04f-b095-4db8-a3ec-fa03f22051f8</element>
7 + </id>
8 + <interactive>false</interactive>
9 + <remote>false</remote>
10 + <verbose>true</verbose>
11 + <property>
12 + <key>extensions</key>
13 + <value>
14 + <list xmlns="" xmlns:ns2="http://www.xwiki.org">
15 + <org.xwiki.extension.ExtensionId>
16 + <id>org.xwiki.contrib.oidc:oidc-authenticator</id>
17 + <version class="org.xwiki.extension.version.internal.DefaultVersion" serialization="custom">
18 + <org.xwiki.extension.version.internal.DefaultVersion>
19 + <string>1.28</string>
20 + </org.xwiki.extension.version.internal.DefaultVersion>
21 + </version>
22 + </org.xwiki.extension.ExtensionId>
23 + </list>
24 + </value>
25 + </property>
26 + <property>
27 + <key>extensions.excluded</key>
28 + <value>
29 + <set xmlns="" xmlns:ns2="http://www.xwiki.org"/>
30 + </value>
31 + </property>
32 + <property>
33 + <key>interactive</key>
34 + <value>
35 + <boolean xmlns="" xmlns:ns2="http://www.xwiki.org">false</boolean>
36 + </value>
37 + </property>
38 + <property>
39 + <key>namespaces</key>
40 + <value>
41 + <list xmlns="" xmlns:ns2="http://www.xwiki.org">
42 + <string>xwiki</string>
43 + </list>
44 + </value>
45 + </property>
46 +</jobRequest>
47 +

Get Connected