Run Domino REST API WOPI with Collabora container
The Domino REST API can function as a WOPI host, allowing WOPI clients to connect. One such WOPI client is Collabora1, an open-source office suite based on LibreOffice2, that enables real-time collaborative document editing in a web browser.
About this task
Guides you on how to set up a local Collabora container and use it to enable real-time collaborative document editing in a web browser.
Before you begin
Download the following zip file to extract the necessary files for setting up a Collabora container.
Procedures
The following procedures guide you in setting up your local Collabora container and configuring it to work with Domino REST API.
Set up the Collabora container
- Navigate to the directory where you downloaded the zip file, and then extract the downloaded zip file. You should see a
config
folder, adocker-compose.yml
file, and areadme.md
file. -
Create an
.env
file using a text editor and include the following configuration parameters.COLLABORA_DOMAIN=office.demo.io:9980 COLLABORA_USER=admin COLLABORA_PASSWORD=secret
-
Save the created
.env
file. - Execute the
docker compose up
command to create and start your Collabora container. -
Once the container is running, open your web browser and navigate to
office.demo.io:9980
. You should see an OK response indicating that the service is operational.
Tip
-
If the container is running but the service is not working, add the following line in your
hosts
file then try again.127.0.0.1 office.demo.io:9980
-
For more information, see the Collabora Installation Guide.
Configure Collabora client to work with Domino REST API
-
Create a document with a file attachment, such as
.pptx
file or.docx
file. Make sure to take note of UNID and dataSource of the document you created. -
Send a POST request to your Domino REST API host
/api/wopi/filetoken?dataSource={dataSource}
with the following body:{ "fileName": "{fileName}", "unid": "{unid}" }
wherein:
{dataSource}
is the name of the dataSource where the document containing the file attachment is located.{fileName}
is the attachment filename.{unid}
is the UNID of the document containing the file attachment.
-
Check the response and take note of the values of the
access_token
,file_id
, andaccess_token_ttl
.The response should include details of the attachment file as shown in the following example response.
{ "dataSource": "testdb", "unid": "A3A40F96234F592A00258CE4002F7E57", "fileName": "sample.docx", "access_token": "3bbf9765cc149c283a37f8ea786269be0cdd63b94f4955da9b054c82bca9ce9caaa0893e37be842b4259baf8bb1eab97c742ab9a66422937cc6d57be9d8841f82b37b98eb0295d0bab0994f322b57efbc6f2f252b346258704af29f4b75bedf4e4737aa2", "file_id": "testdb%7CA3A40F96234F592A00258CE4002F7E57%7Csample.docx", "access_token_ttl": 1755024046000 }
-
Open your browser and go to
office.demo.io:9980/hosting/discovery
where you will see an XML with URLs having the formatoffice.demo.io:9980/browser/{hash}/cool.html?
. Take note of the{hash}
value.In the following example image, the value of
{hash}
is3dc280be53
. -
Construct the URL using the format
{DRAPI_HOST}/api/wopi/files/{file_id}
by replacing the following variables as indicated below:- Substutite
{DRAPI_HOST}
with your Domino REST API hostname. - Substitute
{file_id}
with thefile_id
you took note from the response to the POST request.
The resulting URL will serve as the value assigned to the variable
WOPISrc
. - Substutite
-
Send a POST request to
office.demo.io:9980/browser/{hash}/cool.html?WOPISrc={UrlEncodedWOPISrc}
.wherein:
{hash}
is the value you noted in one of the previous steps.{UrlEncodedWOPISrc}
is the value of theWOPISrc
variable in a URL encoded format.
The request body should be a
multipart/form-data
format, and include the following:access_token
obtained from the response to the POST request you made to your Domino REST API host.- Optional:
access_token_ttl
that can also be obtained from the response to the POST request you made to your Domino REST API host.
Tip
If you can't do a
multipart/form-data
request body, send a GET request to the same URL with theaccess_token
and optionally theaccess_token_ttl
as query parameters.A successful request enables you to view and edit the document using Collabora.