dokuwiki-plugin-struct
dokuwiki-plugin-struct copied to clipboard
Unable to get global data using the XML-RPC API
I have defined a series of schemas to store global data, and I'm trying to access data using the XML-RPC API using cURL.
I am able to get the schema definition with the following request:
<?xml version='1.0'?>
<methodCall>
<methodName>plugin.struct.getSchema</methodName>
<params>
<param>
<value>
<string>firewallzones</string>
</value>
</param>
</params>
</methodCall>
The response is as follows:
<?xml version="1.0"?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member><name>firewallzones</name><value><array><data>
<value><struct>
<member><name>name</name><value><string>name</string></value></member>
<member><name>type</name><value><string>Text</string></value></member>
<member><name>ismulti</name><value><boolean>0</boolean></value></member>
</struct></value>
<value><struct>
<member><name>name</name><value><string>purpose</string></value></member>
<member><name>type</name><value><string>Text</string></value></member>
<member><name>ismulti</name><value><boolean>0</boolean></value></member>
</struct></value>
</data></array></value></member>
</struct>
</value>
</param>
</params>
</methodResponse>
However if I try to get the global data on that schema, I get a meaningless response:
Post data:
<?xml version='1.0'?>
<methodCall>
<methodName>plugin.struct.getData</methodName>
<params>
<param>
<value>
<string>doku:admin</string>
</value>
</param>
<param>
<value>
<string>firewallzones</string>
</value>
</param>
<param>
<value>
<int>0</int>
</value>
</param>
</params>
</methodCall>
Response:
<?xml version="1.0"?>
<methodResponse>
<params>
<param>
<value>
<struct>
<member><name>firewallzones</name><value><struct>
<member><name>name</name><value><string></string></value></member>
<member><name>purpose</name><value><string></string></value></member>
</struct></value></member>
</struct>
</value>
</param>
</params>
</methodResponse>
As you can see, no values are returned, only column names.
Probably not important, but all cURL calls are made as as follows:
curl -X POST https://myserver/lib/exe/xmlrpc.php -H "Content-Type: application/xml" -H "Accept: application/xml" -d "@postData.xml" --cookie cjar
Any ideas? Many thanks for your feedback.
As far as I can tell it is also not possible to write serial or global data with XML-RPC
Would also like this feature
To solve this problem, we can add a new function in remote.php that exposes the schema metadata and its entries along with the IDs
@jorgemarti I would like to contribute to your project but the task description is not clear to me yet, would you contact me now? telegram: https://t.me/smartbigdaddy skype: live:.cid.6685adcfbab15764
Thanks
https://github.com/cosmocode/dokuwiki-plugin-struct/commit/f411d87222d57469b74e2810a1ff3b1f60d1daa8#r152655173
File AccessTable.php line 412 function getDataArray(). this function is not quite right.
its subquently being called in helper.php by the getData function on line 65.
this function is returning an Array of this kind:
`Array ( [cars] => Array ( [bodyType] => [color] => [tires] => [make] => [model] => [year] => )
)` which is not what we are looking for. am really new to looking to this but an extra function in remote.php is not the answer. the sql built from query builder is.
in getDataArray function. there is this call: $data = $this->getDataFromDB(); which inturn calls [$sql, $opt] = $this->buildGetDataSQL($idColumn);
that builds the query that return the empty values. I might need some help understanding the querying mechanism so that I can make a substantial PR for this. my tests after trying create new function in remote.php show me that its not the answer
This PR fixes this issue:
https://github.com/cosmocode/dokuwiki-plugin-struct/pull/732
Example of how to get this data in python:
import dokuwiki
DOKUCONN=dokuwiki.DokuWiki(url='http://yoursite.com',user='username',password='yourpassword')
fetched_schema=DOKUCONN.structs.get_data('','yourschema')