API Save Editing in onlyOffice community server

Good morning, I would like to use the save edit API in the onlyOffice Community server APIs. could you please clarify for me the parameters that sream and doc take please?

Example : {
“fileId”:“344”,
“fileExtension”:“docx”,
“downloadUri”:“xxxxxxxxxxxxxxxxxx/Products/Files/HttpHandlers/filehandler.ashx?action=stream&fileid=344&version=3&stream_auth=xxxxxxxxxxxxxxxxxxxxxxxxxx”,
“stream”: “”,
“doc” :“”

}

response :{
“status”: 1,
“statusCode”: 500,
“error”: {
“message”: “Default constructor not found for type System.IO.Stream”,
“hresult”: -2146233069,
“data”: {}
}
}

1 Like

Hello,
You can leave ‘doc’ field empty, for the most part it is not needed (as it is showed in this documentation - ONLYOFFICE Api Documentation - Save file edits. The value for this parameter can be obtained using the following method - ONLYOFFICE Api Documentation - Get a token for a password-protected external link).
As a whole, stream is a stream of bytes that need to be saved to file (basically, file itself), it can be set to ‘N/A’

Hello,
Thank you for the response, as you can see in the request below I tried
with the parameters “stream”: “N/A” and “doc”: “”
I got the following response:

Request :
{
“fileId”:“344”,
“fileExtension”:“docx”,
“downloadUri”:“XXXXXXXXXXXXXXXXXX/Products/Files/HttpHandlers/filehandler.ashx?action=stream&fileid=161&stream_auth=4XXXXXXXXXXXXXXXXXXXXSQD5NR66FK0SWU1O&X-REWRITER-URL=https%3a%2f%2fXXXXXXXXXXXXXXXXXXXXXXXXX”,
“stream”:“N/A”,
“doc”:“”
}

Response : {
“status”: 1,
“statusCode”: 500,
“error”: {
“message”: “Default constructor not found for type System.IO.Stream”,
“hresult”: -2146233069,
“data”: {}
}
}

1 Like

Please describe in detail the whole use case scenario. What are you trying to do?

1 Like
  • I am in the process of integrating the doc editor into my application.
  • I want to make a manual backup of the editable file.
  • I need the editable file saved with the last modification to convert it to PDF and do my processing.
    -but each time I get a blank page, the file does not take into account the modifications made to the file.
2 Likes

Hello,
Please try to send a request without “stream” parameter, delete it entirely.

Here is an example of a request:

"request": {
          "postData": {
            "params": [],
            "text": "UEsDBBQAAA.....1zAAAAAA==", // this parameter is a Word file in base64 format
            "mimeType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
          },
          "queryString": [],
          "httpVersion": "HTTP/1.1",
          "headers": [
            {
              "value": "someportalalias.onlyoffice.co",
              "name": "Host"
            },
            {
              "name": "Accept-Encoding",
              "value": "br;q=1.0, gzip;q=0.9, deflate;q=0.8"
            },
            {
              "name": "Content-Type",
              "value": "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
            },
            {
              "name": "Accept-Language",
              "value": "en-RU;q=1.0, ru-RU;q=0.9"
            },
            {
              "value": "Bearer 7AV.....To=", 
              "name": "Authorization"
            },
            {
              "name": "User-Agent",
              "value": "some user agent"
            },
            {
              "name": "Content-Length",
              "value": "30802"
            }
          ],
          "method": "PUT",
          "headersSize": 618,
          "bodySize": 30802,
          "cookies": [],
          "url": "https://someportalalias.onlyoffice.co/api/2.0/files/file/7774705/saveediting?"
        }

Hello, thank you for the efforts made.
It should be noted that the purpose of calling the API is to save the contents of the edit file manually.
If I convert the file to base 64 and call the saveedit API, I will not have the latest modifications.
I will have it if only office (document server) does the automatic saving and in this case I will not need to call saveedit.

Hello,
Please clarify, are you integrating ONLYOFFICE Docs (Document Server) with your own application?

Hello
sory for late reply,
I’m talking about the onlyOffice Office Document Server editor.

This method (ONLYOFFICE Api Documentation - Save file edits) can be used only with Portal API (ONLYOFFICE Workspace product), as you have ONLYOFFICE Docs installed, you cannot use the above-mentioned method.
You can configure forcesave (ONLYOFFICE Api Documentation - Saving File), so that when the forcesave request is sent to Callback (ONLYOFFICE Api Documentation - Callback handler), you’ll get a link to the intermediate version of document with last changes made