Use API with JAVA

Integration questions/issues
m.allain
Posts: 12
Joined: Fri Jan 10, 2020 4:12 pm

Use API with JAVA

Post by m.allain » Mon Jan 13, 2020 8:23 am

Hello,

I'm on Ubuntu 18.04 and I installed OnlyOffice (Community Edition) with Docker thanks to the following tutorial https://tutorials.ubuntu.com/tutorial/i ... untu1804#0.

Image

I want to use the Document API in JAVA. I followed the following tutorial https://api.onlyoffice.com/editors/example/java. In step 2, he asked us to change the values in the "settings.properties" file.

Image

What are the values to fill in in relation to my configuration?

In the administrator interface, what is the purpose of this page and how to configure it?

Image

Thank You

Alexandre
Posts: 125
Joined: Thu Dec 12, 2019 11:08 am

Re: Use API with JAVA

Post by Alexandre » Mon Jan 13, 2020 2:59 pm

Hello.
Please note, our official tutorial you can find on our site: https://helpcenter.onlyoffice.com/serve ... ation.aspx
About your question:
What are the values to fill in in relation to my configuration?
Set the name of your server+/ds-vpath/ instead of documentserver. E.g., line files.docservice.url.converter=https://documentserver/ConvertService.ashx transformed to files.docservice.url.converter=https://example.com/ds-vpath/ConvertService.ashx
In the administrator interface, what is the purpose of this page and how to configure it?
This page contains the internal addresses of Document and Community servers which are necessary for editing and storing documents. Please do not change these settings.

m.allain
Posts: 12
Joined: Fri Jan 10, 2020 4:12 pm

Re: Use API with JAVA

Post by m.allain » Mon Jan 13, 2020 3:23 pm

Thank you for the information Alexandre,

As you told me, I left the default settings in the admin interface.
I changed the values in my settings.properties file as below :

Image

When I go on the url "http://xxx.xxx.xxx.xxx:xxx/ds-vpath/ConvertService.ashx, I have good access to the file. Same for the other files.

I then launched the JAVA application (with an Apache Tomcat 9 server). The application launches well but the editor returns me an error :

Image

How do we resolve this error?

Alexandre
Posts: 125
Joined: Thu Dec 12, 2019 11:08 am

Re: Use API with JAVA

Post by Alexandre » Thu Jan 16, 2020 1:39 pm

Please note, values of lines “files.docservice.secret=” and “files.docservice.header=” from your screenshot must match with values on same lines at local.json file from Document Server.

m.allain
Posts: 12
Joined: Fri Jan 10, 2020 4:12 pm

Re: Use API with JAVA

Post by m.allain » Thu Jan 16, 2020 3:02 pm

Hello,

While waiting for your answer, I had time to do some more research and came up with the same solution.
“files.docservice.secret=” and “files.docservice.header=” from your screenshot must match with values on same lines at local.json file from Document Server.
So I tried to change this value in the .json file. Unfortunately, I use Docker and I haven't found a solution to be able to change the values.
I reinstalled OnlyOffice via the modified .sh file.

In the installation file "install.sh", I changed the value of "JWT_SECRET" by my password. The header is automatically modified: "JWT_HEADER=AuthorizationJwt".

Image

I restarted the JAVA project with the new parameters.

Image

The error is still there. Knowing that I use Docker, is there another way to change both values?

Alexandre
Posts: 125
Joined: Thu Dec 12, 2019 11:08 am

Re: Use API with JAVA

Post by Alexandre » Fri Jan 17, 2020 8:37 am

Hello.
Unfortunately, I use Docker and I haven't found a solution to be able to change the values.
Go to Document Server container with command

Code: Select all

docker exec -it 12d bash
→ use command

Code: Select all

nano /etc/onlyoffice/documentserver/local.json
for edit (I took the container name from your first screenshot in topic).
The error is still there.
I offer two options for you.
a) Go to local.json file and find these lines:
},
"token": {
"enable": {
"request": {
"inbox": true,
"outbox": true
},
"browser": true
Set false instead true here. After that use command

Code: Select all

supervisorctl restart all
inside Document Server container. Clean values at lines “files.docservice.secret=” and “files.docservice.header=” at settings.properties file.
Now you need to regenerate .war file and upload it to project via TomCat interface mode.
Check the result.
b) Make clean installation. Do not change install.sh script. Make a single value the lines “files.docservice.secret=” and “files.docservice.header=” like I said in previous posts. Check the result.
Please specify, do you need features of portal or just integration with Java? In second option, you don’t need to install Community Server. Document Server is enough. https://helpcenter.onlyoffice.com/serve ... ation.aspx
I’ll be waiting for your reply.

m.allain
Posts: 12
Joined: Fri Jan 10, 2020 4:12 pm

Re: Use API with JAVA

Post by m.allain » Fri Jan 17, 2020 10:07 am

Hello Alexandre, thank you for your reply.

I made a new clean installation of OnlyOffice.

I modified the values in the "local.json" file as below :

Image

Is that correct?

I relaunched the containers with the command line.

Code: Select all

supervisorctl restart all
I modified the values in the "setttings.properties" file as below :

Image

I recompiled my JAVA project and restarted the Apache Tomcat 9 server. I always make the same mistake. :|

A small precision, Apache Tomcat 9 and OnlyOffice are installed on the same virtual machine. So, normally there shouldn't be any problem to access the file.
Please specify, do you need features of portal or just integration with Java? In second option, you don’t need to install Community Server. Document Server is enough. https://helpcenter.onlyoffice.com/serve ... ation.aspx
I need features of portal.

Alexandre
Posts: 125
Joined: Thu Dec 12, 2019 11:08 am

Re: Use API with JAVA

Post by Alexandre » Fri Jan 17, 2020 12:37 pm

Hello m.allain.
I modified the values in the "local.json" file as below
No, if you made clean installation, you shouldn’t touch lines "inbox",
"outbox" and "browser". Set default value as true. Other lines are correct.
modified the values in the "setttings.properties" file as below
It’s correct.
Once you finished editing local.json use command supervisorctl restart all. Let me know the result.

m.allain
Posts: 12
Joined: Fri Jan 10, 2020 4:12 pm

Re: Use API with JAVA

Post by m.allain » Fri Jan 17, 2020 1:47 pm

No, if you made clean installation, you shouldn’t touch lines "inbox",
"outbox" and "browser". Set default value as true. Other lines are correct.
I set the values to true and restart the containers.
I always get the same mistake... :|

I also tested by replacing in the "settings.properties" file the IP address of my server by "127.0.0.1" (as I am on the same machine). The problem is the same.

Alexandre
Posts: 125
Joined: Thu Dec 12, 2019 11:08 am

Re: Use API with JAVA

Post by Alexandre » Fri Jan 17, 2020 3:11 pm

I have one more point for you. Go to Document Server container and edit local.json file. Set false for lines "inbox", "outbox" and "browser". You should get something like that:
},
"token": {
"enable": {
"request": {
"inbox": false,
"outbox": false
},
"browser": false
After that make command supervisorctl restart all inside the container. Now go to settings.properties file and clean values at lines “files.docservice.secret=” and “files.docservice.header=”. Regenerate your JAVA project and let me know the result.
Also, check logs file of converter service. Go to host and run the command nano /app/onlyoffice/DocumentServer/logs/documentserver/converter/out.log
Do you see any errors?

Post Reply