dokuwiki-plugin-struct icon indicating copy to clipboard operation
dokuwiki-plugin-struct copied to clipboard

Unable to get global data using the XML-RPC API

Open jorgemarti opened this issue 4 years ago • 6 comments

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.

jorgemarti avatar Jul 01 '21 07:07 jorgemarti

As far as I can tell it is also not possible to write serial or global data with XML-RPC

sirtoobii avatar May 26 '22 06:05 sirtoobii

Would also like this feature

springfielddatarecovery avatar Feb 12 '25 23:02 springfielddatarecovery

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

ayebrx avatar Feb 12 '25 23:02 ayebrx

@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

smart-tech-master avatar Feb 12 '25 23:02 smart-tech-master

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

serunkuma avatar Feb 17 '25 19:02 serunkuma

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')

springfielddatarecovery avatar Mar 13 '25 01:03 springfielddatarecovery