# Importing canvas workpads via saved-objects API results in internal server error

**URL:** <https://discuss.elastic.co/t/importing-canvas-workpads-via-saved-objects-api-results-in-internal-server-error/199837>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [September 17, 2019, 2:09pm UTC](https://discuss.elastic.co/t/importing-canvas-workpads-via-saved-objects-api-results-in-internal-server-error/199837 "2019-09-17T14:09:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tarkin67](https://avatars.discourse-cdn.com/v4/letter/t/8797f3/32.png) [@tarkin67](https://discuss.elastic.co/u/tarkin67)\
**Post date:** [September 17, 2019, 2:09pm UTC](https://discuss.elastic.co/t/importing-canvas-workpads-via-saved-objects-api-results-in-internal-server-error/199837/1 "2019-09-17T14:09:36Z")

</div>

Hi all,

I am running into an issue with importing canvas workpads via the saved-objects API. We have implemented a script that fetches saved objects via "/api/saved\_objects". The script fetches kibana dashboards, visualizations, index patterns and canvas workpads. This works fine, there are no problems and we get a list of JSON files representing the fetched saved objects.

For populating an empty kibana instance, these JSON files are then again posted to the saved-objects API. This works perfectly fine for all the saved objects except for the canvas workpads: The POST request for the workpads succeeds and they are then shown in the canvas workpad list. However, when clicking a workpad, kibana displays that an internal server error occurred and does not open the workpad:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/3/83f6042492375f4cb1f847abf6bcdff2aca56a55.png)

In the kibana server log the following error gets spammed:

```
 error [14:00:16.933] [warning][stats-collection] TypeError: Cannot read property 'length' of undefined
at length (C:\dev\Software\elastic\kibana-7.3.1-windows-x86_64\x-pack\legacy\plugins\canvas\server\usage/workpad_collector.js:51:92)
at Array.reduce (<anonymous>)
at reduce (C:\dev\Software\elastic\kibana-7.3.1-windows-x86_64\x-pack\legacy\plugins\canvas\server\usage/workpad_collector.js:51:41)
at Array.map (<anonymous>)
at map (C:\dev\Software\elastic\kibana-7.3.1-windows-x86_64\x-pack\legacy\plugins\canvas\server\usage/workpad_collector.js:37:36)
at summarizeWorkpads (C:\dev\Software\elastic\kibana-7.3.1-windows-x86_64\x-pack\legacy\plugins\canvas\server\usage/workpad_collector.js:158:12)
at process._tickCallback (internal/process/next_tick.js:68:7)
log [14:00:16.956] [warning][stats-collection] Unable to fetch data from canvas collector

```

The obtained JSON for the workpad is the following:

```
{
"id": "workpad-d4fd2982-2301-4aca-b341-e2d683f94f86",
"type": "canvas-workpad",
"updated_at": "2019-09-17T13:49:52.305Z",
"version": "WzI2MCwyXQ==",
"attributes": {
                   "name": "test",
                   "width": 1080,
                   "height": 720,
                   "css": ".canvasPage {\n\n}",
                   "page": 0,
                   "pages": [
                                 {
                                     "id": "page-3d6133cd-7077-4775-9042-e532b463107f",
                                     "style": {
                                                   "background": "#FFF"
                                               },
                                     "transition": {

                                                    },
                                     "elements": [
                                                      {
                                                          "id": "element-4852d2bf-393f-4874-811e-b5309d8a6d6e",
                                                          "position": {
                                                                           "left": 20,
                                                                           "top": 20,
                                                                           "width": 700,
                                                                           "height": 300,
                                                                           "angle": 0
                                                                       },
                                                          "expression": "filters\n| demodata\n| pointseries x=\"project\" y=\"sum(price)\" color=\"state\" size=\"size(username)\"\n| plot defaultStyle={seriesStyle points=5 fill=1}\n| render"
                                                      }
                                                  ],
                                     "groups": [

                                                ]
                                 }
                             ],
                   "colors": [
                                  "#37988d",
                                  "#c19628",
                                  "#b83c6f",
                                  "#3f9939",
                                  "#1785b0",
                                  "#ca5f35",
                                  "#45bdb0",
                                  "#f2bc33",
                                  "#e74b8b",
                                  "#4fbf48",
                                  "#1ea6dc",
                                  "#fd7643",
                                  "#72cec3",
                                  "#f5cc5d",
                                  "#ec77a8",
                                  "#7acf74",
                                  "#4cbce4",
                                  "#fd986f",
                                  "#a1ded7",
                                  "#f8dd91",
                                  "#f2a4c5",
                                  "#a6dfa2",
                                  "#86d2ed",
                                  "#fdba9f",
                                  "#000000",
                                  "#444444",
                                  "#777777",
                                  "#BBBBBB",
                                  "#FFFFFF",
                                  "rgba(255,255,255,0)"
                              ],
                   "isWriteable": true,
                   "assets": {

                              },
                   "@timestamp": "2019-09-17T13:49:52.253Z",
                   "@created": "2019-09-17T13:49:45.304Z"
               },
"references": [

               ],
"migrationVersion": {
                         "canvas-workpad": "7.0.0"
                     }
}

```

What exactly is breaking here, and what would be the correct way to fetch canvas workpads via the saved-objects API?

Thanks and regards

---

<div class="post-metadata">

**Author:** ![bhavyarm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bhavyarm/32/22392_2.png) [@bhavyarm](https://discuss.elastic.co/u/bhavyarm)\
**Post date:** [September 17, 2019, 2:25pm UTC](https://discuss.elastic.co/t/importing-canvas-workpads-via-saved-objects-api-results-in-internal-server-error/199837/2 "2019-09-17T14:25:22Z")

</div>

That looks like a bug:

can you please log it here? [https://github.com/elastic/kibana/issues](https://github.com/elastic/kibana/issues)

Thanks,  
Bhavya

---

<div class="post-metadata">

**Author:** ![tarkin67](https://avatars.discourse-cdn.com/v4/letter/t/8797f3/32.png) [@tarkin67](https://discuss.elastic.co/u/tarkin67)\
**Post date:** [September 17, 2019, 2:52pm UTC](https://discuss.elastic.co/t/importing-canvas-workpads-via-saved-objects-api-results-in-internal-server-error/199837/3 "2019-09-17T14:52:08Z")

</div>

Hi @bhavyarm

Thank you for the quick reply, I have created [this](https://github.com/elastic/kibana/issues/45901) issue over on github.

Kind regards

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 15, 2019, 3:01pm UTC](https://discuss.elastic.co/t/importing-canvas-workpads-via-saved-objects-api-results-in-internal-server-error/199837/4 "2019-10-15T15:01:37Z")

</div>

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