Document converter fail to get document from OO server

I try to use the document conversion API with a document uploaded to OO server.

So I upload my document with the api to a given common folder. It’s working fine. I find this document in the portail and I can edit it with the editors.

Now, I try to use the conversion API to convert it to pdf (docx to pdf). Whenever I try to use the api with a document store on the only office server, it fails with an “error -4”.

If i use a url outside of OnlyOffice but on our internal servers with a document, it work without any error…

the url given by the upload api is: http://onlyoffice.internal.srv/Products/Files/httphandlers/filehandler.ashx?action=download&fileid=71

and here is the JSON I send to the conversion service

{
	"async":false,
	"filetype":"docx",
	"key":"5cb6191b8c8442",
	"outputtype":"pdf",
	"title":"DocAFaireEnPDF.docx",
	"url":"http://onlyoffice.internal.srv/Products/Files/httphandlers/filehandler.ashx?action=download&fileid=71"
}

What I’m missing to make it work from a file stored in the OnlyOffice server ?

Hello @Christian
Please clarify what you mean by ‘OO server’. Do you mean integrated example of a storage which is available on https://domain_name/example or Workspace? If you mean Workspace (Groups) product, I believe this is expected behaviour since you should use authentication token to operating with portal files. Please check it out for example:
https://api.onlyoffice.com/portals/method/files/get/api/2.0/files/file/{fileid}/presigneduri
https://api.onlyoffice.com/portals/method/authentication/post/api/2.0/authentication

If I misunderstood your request, please clarify it.

Hello @Alexandre,

OOServer means the server where I installed all the OnlyOffice Package.

I upload the documents to this Workspace:

Then I want to use the document API conversion to convert this file to a PDF. But when I try it, the converter seems to have a problem with downloading this file to convert it to pdf.
If I use a public free URL (IE a file stored in a public URL), it works without problem

Hello @Christian
Please pay attention to this method https://api.onlyoffice.com/portals/method/files/get/api/2.0/files/file/{fileid}/presigneduri
You have to get download link by this method

@Alexandre, I use this URL but it doesn’t work…

Here is the JSON i use to convert the docx file to pdf

{
	"async":false,
	"filetype":"docx",
	"key":"72fe06fb2c7145",
	"outputtype":"pdf",
	"title":"DocAFaireEnPDF.docx",
	"url":"http://my.onlyoffice.server/api/2.0/files/file/76",
	"token":"zXuSab69+f6rHz0Cg+2ZQ0DpCsJvZ7DNg9bT7b+eRP+hxOxzqg0zoljjXihokWbpjQQne7gzxdISt6t\/V59uWd1zpogEfTo8r59pxacQlycIWlpBLeuXMzfm9GYd50Hhg0mSa5JpiDfDLvF9wTVmYA=="
}

Then I call the converter API at http://my.onlyoffice.server:8083/ConvertService.ashx
I pass the token in the Authorization header to the converter API too

But it always return a -4 error

<?xml version="1.0" encoding="UTF-8"?>
<FileResult>
  <Error>-4</Error>
</FileResult>

But if I change in the JSON : “url”:“http://my.onlyoffice.server/api/2.0/files/file/76” to a public URL it converts the document without any problem. So I don’t know why it’s not working with documents uploaded to OnlyOffice…

You have incorrect link to the file in your example. I prepared a short demonstration, please pay attention to that I use Get file download link method when file is uploaded to a portal to collect necessary link.

@Alexandre
Thanks, but I have a problem with the url described in the API here " GET api/2.0/files/file/{fileId}/presigneduri"

When I try to use if (With OnlyOffice 6 or 7) I got an http 404 error.
I have to remove the “/presigneduri” to make it work but then the results are not the same as in your video

So this url
http://my.onlyoffice.server/api/2.0/files/file/15/presigneduri” ==> http404
http://my.onlyoffice.server/api/2.0/files/file/15” ==> http200 and I got a json but not with all the token in the link like in your url

without the /presigneduri I got the following json

{
   "count": 1,
   "status": 0,
   "statusCode": 200,
   "response":    {
      "folderId": 6,
      "version": 1,
      "versionGroup": 1,
      "contentLength": "21,65 ko",
      "pureContentLength": 22173,
      "fileStatus": 0,
      "viewUrl": "http://my.onlyoffice.server/Products/Files/HttpHandlers/filehandler.ashx?action=download&fileid=15",
      "webUrl": "http://my.onlyoffice.server/Products/Files/DocEditor.aspx?fileid=15",
      "fileType": 5,
      "fileExst": ".xlsx",
      "comment": "Chargée",
      "id": 15,
      "title": "calendrier-2022.xlsx",
      "access": 0,
      "shared": false,
      "rootFolderType": 1,
      "updatedBy":       {
         "id": "64aa05c3-dac8-11ec-9ee5-0800276013f6",
         "displayName": "Administrator ",
         "avatarSmall": "/skins/default/images/default_user_photo_size_32-32.png?_=-863449106",
         "profileUrl": "http://my.onlyoffice.server/Products/People/Profile.aspx?user=administrator"
      },
      "created": "2022-06-02T19:52:38.0000000+02:00",
      "createdBy":       {
         "id": "64aa05c3-dac8-11ec-9ee5-0800276013f6",
         "displayName": "Administrator ",
         "avatarSmall": "/skins/default/images/default_user_photo_size_32-32.png?_=-863449106",
         "profileUrl": "http://my.onlyoffice.server/Products/People/Profile.aspx?user=administrator"
      },
      "updated": "2022-06-02T19:52:38.0000000+02:00"
   }
}

So why with the “/presignedurl”, the server reply with http 404 ???

Thanks

@Christian
Sorry for the late reply.

When I try to use if (With OnlyOffice 6 or 7) I got an http 404 error.

Please clarify what you mean by ‘6 or 7’. ‘presigneduri’ is a portal method, but not Document server one.

@Alexandre,
I hope you’ll see my answer. It seems that my post was automatically hidden for spam reasons ??? Maybe because I posted all the urls I used/try ???

Probably forum settings marked your posts as spam. But I checked them yesterday and restored all of them. But I don’t see a new one. Could you please post again?

@Alexandre

So here is my real setup…

All OnlyOffice components are installed on the same server… Only available on a LAN with ActiveDirectory domain

The portal is on the following server: http://my.onlyoffice.server

The document-server is on: http://my.onlyoffice.server:8083

The file I’m trying to convert has the following url when I display it on the portal: http://my.onlyoffice.server/Products/Files/doceditor.aspx?fileid=80

So the URL I had to call to get the download URL for the Converter is: http://my.onlyoffice.server/api/2.0/files/file/80/presigneduri

The URL I call for the Conversion API is: http://my.onlyoffice.server:8083/ConvertService.ashx

So why only the url http://my.onlyoffice.server/api/2.0/files/file/80/presigneduri fails with 404 errors ???

@Christian
Please reproduce the issue and make a screenshot of your presigneduri request and response. Hide your domain name on the screenshot, but do not touch anything else.

@Alexandre

Here are screenshots done with PostMan…

  1. Authentication to get a token

  2. Upload a docx file with the token in “Authorization” header. And Got the response with file id 87.

  3. Get the presigned URL with the token in header id file id 87 in url
    Result fails with 404 error

Thank you for provided screenshots. Please let us know your Community server version

@Alexandre

I think it’s version 10.5.789 (version shown in the about box of the portal page)
Document server is version 5.4.2

I think we have found the issue. The mentioned method (ONLYOFFICE Api Documentation - Get file download link) is for the latest Community server version (v.12).
Please update your installation and let us know the result.
NB! We strongly recommend to prepare whole server backup before update process.