Try the fastest and simplest way to install ONLYOFFICE

[API] Document command service

Tech support for Enterprise Version

[API] Document command service

Postby dsi-lille » Mon Jan 30, 2017 9:44 am

Hi,

i try to use the document command service and especially the drop command.

But in the log of the document server, i get this error :

Code: Select all
[2017-01-30 10:17:54.299] [ERROR] nodeJS - error parseReplyData: docId = bJmabKfLlxWteH7BM1U_; data = 549aec5a-e3cd-11e6-be5e-0242ac120004
SyntaxError: Unexpected token a in JSON at position 3
    at Object.parse (native)
    at parseReplyData (/var/www/onlyoffice/documentserver/server/DocService/sources/DocsCoServer.js:614:18)
    at dropUsersFromDocument (/var/www/onlyoffice/documentserver/server/DocService/sources/DocsCoServer.js:629:15)
    at next (native)
    at /var/www/onlyoffice/documentserver/server/DocService/sources/DocsCoServer.js:2304:22
    at next (native)
    at onFulfilled (/var/www/onlyoffice/documentserver/server/DocService/node_modules/co/index.js:65:19)
    at /var/www/onlyoffice/documentserver/server/DocService/node_modules/co/index.js:54:5
    at co (/var/www/onlyoffice/documentserver/server/DocService/node_modules/co/index.js:50:10)
    at exports.commandFromServer (/var/www/onlyoffice/documentserver/server/DocService/sources/DocsCoServer.js:2251:10)


Below, the request i send with PHP :

Code: Select all
array(1) {
  ["http"]=>
  array(4) {
    ["method"]=>
    string(4) "POST"
    ["header"]=>
    string(64) "Content-Type: application/json
Host: escola.expr.in.ac-lille.fr"
    ["ignore_errors"]=>
    bool(false)
    ["content"]=>
    string(90) "{"c":"drop","key":"bJmabKfLlxWteH7BM1U_","users":["549aec5a-e3cd-11e6-be5e-0242ac120004"]}"
  }
}



I take a look a the DocsCoServer.js and i think the problem came from the line 613

Code: Select all
res = JSON.parse(replyData);


replyData is an OBJECT and not a string.
According to the documentation (https://developer.mozilla.org/fr/docs/W ... JSON/parse), JSON.parse take a string in parameters and not an object.

Something like this solve the issue :

Code: Select all
res = JSON.parse(JSON.stringify(replyData));


Could you correct this ?

Thanks,
Yoann
dsi-lille
 
Posts: 111
Joined: Mon Jul 11, 2016 1:47 pm

Re: [API] Document command service

Postby Maxim » Mon Jan 30, 2017 1:15 pm

Hello Yoann!
We have detected this bug and we will fix it next realese! For now you can use
Code: Select all
"users":"[\"549aec5a-e3cd-11e6-be5e-0242ac120004\"]"

users - type string
Maxim
 
Posts: 1072
Joined: Tue Oct 11, 2016 2:34 pm

Re: [API] Document command service

Postby dsi-lille » Mon Jan 30, 2017 2:36 pm

Thanks a lot !
Yoann
dsi-lille
 
Posts: 111
Joined: Mon Jul 11, 2016 1:47 pm

Re: [API] Document command service

Postby Maxim » Tue Jan 31, 2017 7:54 am

You're always welcome!
Maxim
 
Posts: 1072
Joined: Tue Oct 11, 2016 2:34 pm


Return to Enterprise Version

Who is online

Users browsing this forum: No registered users and 1 guest

cron