Getting an Error 400 response to my API request (Docker)

Hello,
I am getting an error 400 response when I try to use the API on my sample app.
{“code”:0,“message”:“Transport unknown”}

This is the code of my sample app (which I copied from here Basic concepts - ONLYOFFICE Api Documentation
)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>
<body>

    <div id="placeholder"></div>
<script type="text/javascript" src="http://0.0.0.0/web-apps/apps/api/documents/api.js"></script>

<script>
    config = {
    "document": {
        "fileType": "docx",
        "key": "https://jwt.io/#debugger-io?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.G0X_hg_UT05tEzRrZqW9EEfDMgeBqlxqBHbsmT9liYs",
        "title": "Example Document Title.docx",
        "url": "http://0.0.0.0/url-to-example-document.docx"
    },
    "documentType": "word",
    "editorConfig": {
        "callbackUrl": "http://0.0.0.0/url-to-callback.ashx"
    }
};
var docEditor = new DocsAPI.DocEditor("placeholder", config);

    </script>
    
</body>
</html>

Some Logs (Feel free to ask for more)

/var/log/onlyoffice/documentserver/docservice/out.log
[2024-10-25T15:18:52.323] [WARN] [localhost] [docId] [userId] nodeJS - io.connection_error code=0, message=Transport unknown

*/var/log/onlyoffice/documentserver/docservice/out.log *
syscall: ‘open’,
path: ‘/var/www/onlyoffice/documentserver/…/Data/license.lic’
}
[2024-10-25T15:10:05.698] [WARN] [localhost] [docId] [userId] nodeJS - [Error: ENOENT: no such file or directory, open ‘/var/www/onlyoffice/documentserver/…/Data/license.lic’] {
errno: -2,
code: ‘ENOENT’,
syscall: ‘open’,
path: ‘/var/www/onlyoffice/documentserver/…/Data/license.lic’
}
[2024-10-25T15:10:05.835] [WARN] [localhost] [docId] [userId] nodeJS - Express server listening on port 8000 in production-linux mode. Version: 8.2.0. Build: 143

Hello @humamdev

Please specify where do you see error 400 exactly as in none of the mentioned log entries contain it. Is it from browser console when accessing editors?

From provided example I understand that you are trying to open a document to edit. Please refer to this article to find out more about that process: Opening File - ONLYOFFICE Api Documentation

By the way, do you use Enterprise or Developer edition of Document Server for this test?

I am using developer edition.
Thank you for the link, I see what I’m supposed to do.

However, when it comes to JSON tokens, where exactly would I find the data that I could insert in the payload and secret into the JSON generator? Would it be in the local.json file, if so, where?

This is how I fixed my code


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

</head>
<body>

    <div id="placeholder"></div>
<script type="text/javascript" src="http://0.0.0.0/web-apps/apps/api/documents/api.js"></script>

<script>
new DocsAPI.DocEditor("placeholder", {
    "document": {
        "fileType": "docx",
        "key": "Khirz6zTPdfd7",
        "title": "Example Document Title.docx",
        "url": "https://0.0.0.0/url-to-example-document.docx"
    },
    "documentType": "word",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkb2N1bWVudCI6eyJmaWxlVHlwZSI6ImRvY3giLCJrZXkiOiJLaGlyejZ6VFBkZmQ3IiwidGl0bGUiOiJFeGFtcGxlIERvY3VtZW50IFRpdGxlLmRvY3giLCJ1cmwiOiJodHRwczovL2V4YW1wbGUuY29tL3VybC10by1leGFtcGxlLWRvY3VtZW50LmRvY3gifSwiZG9jdW1lbnRUeXBlIjoid29yZCJ9.7IpEJxdOvBQ0kJ8l6ZegIV4tX5vsPbZZCDDVmcFROXc"
})

    </script>
    
</body>
</html>

Should I replace key and token, and with what?

Please find out more here:
https://api.onlyoffice.com/docs/docs-api/additional-api/signature/

As an independent integrator, token must be generated when forming request to open a document from your app. You can check out this article to find more about the content of the token:
https://api.onlyoffice.com/docs/docs-api/additional-api/signature/browser/