Using the Tables API: Partial Success and 1 Problem

Hi,
I was able to use the Tables API to GET tables, rows, columns and to POST new rows, I was also able to POST a new table, but I was not able to create a new column.
Here is a working Python function to create a table as an example:

def createtable (self, name: str):
    response = requests.post(
        f"{nextcloud_url}/index.php/apps/tables/api/1/tables?title={name}",
        headers={"OCS-APIRequest": "true"},
        auth=(username, password_encoded)
    return response.json()

So I expected the following to work as well:

    response = requests.post(
        f"{nextcloud_url}/index.php/apps/tables/api/1/tables/{self.myid}/columns?title=TESTTITLE",
        headers={"OCS-APIRequest": "true"},
        auth=(username, password_encoded)
    )

But it doesn’t.

Documentation is here: Swagger UI

To simplify experimentation, I used curl as well:

curl -X POST -u myusername:'mypassword' 
https://someserver.net/index.php/apps/tables/api/1/tables/15/columns'  -d 'title=TESTTITEL'  -H 
"OCS-APIRequest: true" 

Didn’t work either, while this works:

 curl -X GET -u myusername:'mypassword' 
'https://someserver.net/index.php/apps/tables/api/1/columns/46' -H "OCS-APIRequest: true" | 
json_pp 

So my questions are:

  • How do I create a table column, be it in Python or using curl?
  • Is there a more complete documentation for the API’s of Nextcloud Apps?
  • Is there a possibility to retrieve the documentation from the API itself?

Thanks in advance!

Hi,

unfortunately the actual api docs are fuzzy. But there is more to come.

To create a column the app needs to know some more information such as column type etc. You can take a look here: Swagger UI

Hope that helps.

Thanks, the following works:

curl -X 'POST' -u admin:'mypassword' 'https://xxx.someserver.dynv6.net/index.php/apps/tables/api/1/tables/24/columns?title=testspalte3&type=text&subtype=line&mandatory=0' -H 'accept: application/json' -d '' | json_pp

When I tried it first with just the fields marked “mandatory” (i.e., without subtype), I tried to open the table, but it seemed to work forever but didn’t display anything. Fortunately, I tried this with a test table, because I had to delete it.

But with subtype, it works. I suggest that subtype should be marked “mandatory”, at least for text fields.

Thanks a lot, Florian,

This works:

curl -X ‘POST’ -u admin:‘mypassword’ ‘https://xxx.someserver.dynv6.net/index.php/apps/tables/api/1/tables/24/columns?title=testspalte3&type=text&subtype=line&mandatory=0’ -H ‘accept: application/json’ -d ‘’ | json_pp

When I tried it first with just the fields marked “mandatory” (i.e., without subtype), I tried to open the table, but it seemed to work forever but didn’t display anything. Fortunately, I tried this with a test table, because I had to delete it.

But with subtype, it works. I suggest that subtype should be marked “mandatory”, at least for text fields, and also, if an example for curl would be provided, it would be very helpful.

Thanks again, kind regards,

JĂŒrgen

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.