# POST to /api/canvas/workpad with overwrite option

**URL:** <https://discuss.elastic.co/t/post-to-api-canvas-workpad-with-overwrite-option/167362>\
**Category:** Kibana\
**Tags:** canvas\
**Created:** [February 6, 2019, 10:32pm UTC](https://discuss.elastic.co/t/post-to-api-canvas-workpad-with-overwrite-option/167362 "2019-02-06T22:32:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rcodestuff](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@rcodestuff](https://discuss.elastic.co/u/rcodestuff)\
**Post date:** [February 6, 2019, 10:32pm UTC](https://discuss.elastic.co/t/post-to-api-canvas-workpad-with-overwrite-option/167362/1 "2019-02-06T22:32:57Z")

</div>

Hi,  
Using curl I can post a new workpad to canvas like this:  
curl -X POST -H "kbn-xsrf: reporting" -H "Content-Type: application/json" -d @myworkpad.json "/api/canvas/workpad"

In the json I am posting I am setting up a custom id for the workpad. If I want to repost(overwrite) to same id then I get a conflict message back and repost is not allowed.

Question: Is there an option to pass in an overwrite query parameter that would allow repost and hence overwrite of the data associated with the id?

I could use PUT to post to a specific id to overwrite it, but that works if the id already exists. IF it does not exist then PUT will not overwrite the data associated with the id.

Thanks

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [February 7, 2019, 7:42am UTC](https://discuss.elastic.co/t/post-to-api-canvas-workpad-with-overwrite-option/167362/2 "2019-02-07T07:42:39Z")

</div>

could you also post the json you are posting (or multiple of them describing all the scenarios).

---

<div class="post-metadata">

**Author:** ![rcodestuff](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@rcodestuff](https://discuss.elastic.co/u/rcodestuff)\
**Post date:** [February 7, 2019, 11:02am UTC](https://discuss.elastic.co/t/post-to-api-canvas-workpad-with-overwrite-option/167362/3 "2019-02-07T11:02:28Z")

</div>

Below is a sample json I have posted.  
If I try to post to same id again I get the following message:  
{"message":"[doc][canvas-workpad:wpad-json-to-upload]: version conflict, document already exists (current version [1]): [version\_conflict\_engine\_exception] [doc][canvas-workpad:wpad-json-to-upload]: version conflict, document already exists (current version [1]), with { index\_uuid="0AxCM1AlQjWDtTjX1LHTRw" & shard="0" & index=".kibana\_1" }","statusCode":409,"error":"Conflict"}

Sample Json:

```
{
    "name": "wpad-json-to-upload",
    "id": "wpad-json-to-upload",
    "width": 1080,
    "height": 720,
    "css": ".canvasPage {\n\n}",
    "page": 0,
    "pages": [
        {
            "id": "page-6105ff33-1df0-4317-b90a-2f4d1b673da2",
            "style": {
                "background": "#FFF"
            },
            "transition": {},
            "elements": [
                {
                    "id": "element-757ce23a-f664-409f-b4ce-cd9ac9dc1c00",
                    "position": {
                        "left": 20,
                        "top": 20,
                        "width": 500,
                        "height": 300,
                        "angle": 0
                    },
                    "expression": "filters\n| demodata\n| markdown \"Hello World\"\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,
    "@timestamp": "2019-02-07T10:56:22.094Z",
    "@created": "2019-02-07T10:54:31.650Z",
    "assets": {}
}
```

---

<div class="post-metadata">

**Author:** ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)\
**Post date:** [February 11, 2019, 8:04am UTC](https://discuss.elastic.co/t/post-to-api-canvas-workpad-with-overwrite-option/167362/4 "2019-02-11T08:04:22Z")

</div>

you can't create multiple documents with same id ... the second time you want to modify it you should use PUT

---

<div class="post-metadata">

**Author:** ![rcodestuff](https://avatars.discourse-cdn.com/v4/letter/r/839c29/32.png) [@rcodestuff](https://discuss.elastic.co/u/rcodestuff)\
**Post date:** [February 22, 2019, 11:31am UTC](https://discuss.elastic.co/t/post-to-api-canvas-workpad-with-overwrite-option/167362/5 "2019-02-22T11:31:27Z")

</div>

OK Thanks.

---

<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:** [March 22, 2019, 11:37am UTC](https://discuss.elastic.co/t/post-to-api-canvas-workpad-with-overwrite-option/167362/6 "2019-03-22T11:37:27Z")

</div>

Closed on March 22, 2019, 11:37am UTC

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