Create two attachments columns in a Coda table. Add a single row. In one of the columns upload a single file. In the other one upload two files.
Now, call the listRows endpoint and the listColumns endpoint.
For the response from listColumns you’ll see something like:
<snip>
{
"id": "c-pi61voPZCW",
"type": "column",
"name": "File",
"href": "https://coda.io/apis/v1/docs/w6a4yfCsS8/tables/grid-D_ggLbyTu2/columns/c-pi61voPZCW",
"format": {
"type": "attachments",
"isArray": true
}
},
{
"id": "c-iqsqt4e271",
"type": "column",
"name": "File Multiple",
"href": "https://coda.io/apis/v1/docs/w6a4yfCsS8/tables/grid-D_ggLbyTu2/columns/c-iqsqt4e271",
"format": {
"type": "attachments",
"isArray": true
}
}
<snip>
As you can see, both of them say that they are an attachment format type, and that they return arrays "isArray": true
.
However, if you look at the response from listRows, you’ll be surprised.
The multiple attachment columns is correct, it returns an array:
<snip>
"c-iqsqt4e271": [
{
"@context": "http://schema.org/",
"@type": "ImageObject",
"name": "cra.ps",
"height": "",
"width": "",
"url": "https://codahosted.io/docs/w6a4yfCsS8/blobs/bl-mweY1eJZqh/redacted",
"status": "live"
},
{
"@context": "http://schema.org/",
"@type": "ImageObject",
"name": "FCounter.mp4",
"height": "",
"width": "",
"url": "https://codahosted.io/docs/w6a4yfCsS8/blobs/bl-WuR_8Wv6B5/redacted",
"status": "live"
}
]
But the single attachment is incorrect, it returns an object:
<snip>
"c-pi61voPZCW": {
"@context": "http://schema.org/",
"@type": "ImageObject",
"name": "cra.ps",
"height": "",
"width": "",
"url": "https://codahosted.io/docs/w6a4yfCsS8/blobs/bl-mweY1eJZqh/redacted",
"status": "live"
}
This is especially confusing because the rest of the API is quite happy returning single objects as arrays. For example, even though in a Single Select list there can only return one object, the API still returns that single object in an array:
"c-TmORamz3zI": [
0
]
So this seems to add additional reason why we would expect a single attachment to also be returned as an array.
Is this intentional? I know I can just introspect on whether the returned object is an array. But the inconsistency between getColumns and getRows messes up my ability to rely on getColumns as a way to predict what type of data container I need to be ready to handle.