# How to update/create a Dashboard using document service of Dynatrace?

**URL:** <https://community.dynatrace.com/t/how-to-update-create-a-dashboard-using-document-service-of-dynatrace/40695>\
**Category:** Automations\
**Tags:** workflows, dashboards\
**Created:** [July 14, 2023, 8:32am UTC](https://community.dynatrace.com/t/how-to-update-create-a-dashboard-using-document-service-of-dynatrace/40695 "2023-07-14T08:32:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![heramb\_sawant](https://avatars.discourse-cdn.com/v4/letter/h/c4cdca/32.png) [@heramb\_sawant](https://community.dynatrace.com/u/heramb_sawant)\
**Post date:** [July 14, 2023, 8:32am UTC](https://community.dynatrace.com/t/how-to-update-create-a-dashboard-using-document-service-of-dynatrace/40695/1 "2023-07-14T08:32:37Z")

</div>

Hi Team,  
I am creating a workflow in the new Dynatrace; this workflow has a DQL query as 1st task, and then in 2nd task(js code)&nbsp; I want to add this DQL result to the dashboard. Here I want to update the dashboard by DQL results.

How to do that? Somebody, please provide some examples.

I read somewhere using document service, we can create a notebook, similarly, I want to create a dashboard using js code.

Regards,  
Heramb

Regards,  
Heramb Sawant

---

<div class="post-metadata">

**Author:** ![Fin\_Ubels](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/fin_ubels/32/18008_2.png) [@Fin\_Ubels](https://community.dynatrace.com/u/Fin_Ubels)\
**Post date:** [July 18, 2023, 3:47am UTC](https://community.dynatrace.com/t/how-to-update-create-a-dashboard-using-document-service-of-dynatrace/40695/2 "2023-07-18T03:47:29Z")

</div>

Hey Heramb,

You can use the new platform API for this. To get there you would go to [https://Your.Tenant.Address.com/platform/swagger-ui/index.html?urls.primaryName=Document%20Service#/](https://Your.Tenant.Address.com/platform/swagger-ui/index.html?urls.primaryName=Document%20Service#/). Currently this is documented in our developer docs here&nbsp;[Platform services | Dynatrace Developer](https://developer.dynatrace.com/platform-services/#swagger-ui)

Then from there you could follow the following steps to see how the document creation and editing process works as well as the format for requests:

1. GET /documents to find the ID of an example dashboard or notebook you want to use as a template.
2. GET /documents/{id}/content to get the layout that you would need to mimic.
3. POST /documents to then post an example document.

Once you have a template setup you would then in your script just do POST /documents to create a new document with your desired DQL OR do PUT /documents/{id}/content to update an already existing document with your DQL query.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![heramb\_sawant](https://avatars.discourse-cdn.com/v4/letter/h/c4cdca/32.png) [@heramb\_sawant](https://community.dynatrace.com/u/heramb_sawant)\
**Post date:** [July 18, 2023, 5:12am UTC](https://community.dynatrace.com/t/how-to-update-create-a-dashboard-using-document-service-of-dynatrace/40695/3 "2023-07-18T05:12:08Z")

</div>

Hey thanks Fin for your help. This will definitely help to move forward.

Regards,  
Heramb

---

<div class="post-metadata">

**Author:** ![heramb\_sawant](https://avatars.discourse-cdn.com/v4/letter/h/c4cdca/32.png) [@heramb\_sawant](https://community.dynatrace.com/u/heramb_sawant)\
**Post date:** [September 11, 2023, 10:04am UTC](https://community.dynatrace.com/t/how-to-update-create-a-dashboard-using-document-service-of-dynatrace/40695/4 "2023-09-11T10:04:38Z")

</div>

Hey ,  
I m trying to update my own dashboard( having id&nbsp;**f3592b6d-XXXXXXXX411ae35)** using&nbsp; “updateDocumentContent” method but getting below exception

**Uncaught (in promise) 409: Share of type ‘environment’ with access ‘read’ already exists for document ‘f3592b6d-XXXXXXXX411ae35’. errorRef: 282afd6c-2125-435b-8af5-f92fd10d670a**

What needs to be changed?? and What should be the value of&nbsp; **optimisticLockingVersion**???

Regards,  
Heramb

---

<div class="post-metadata">

**Author:** ![heramb\_sawant](https://avatars.discourse-cdn.com/v4/letter/h/c4cdca/32.png) [@heramb\_sawant](https://community.dynatrace.com/u/heramb_sawant)\
**Post date:** [September 12, 2023, 6:44am UTC](https://community.dynatrace.com/t/how-to-update-create-a-dashboard-using-document-service-of-dynatrace/40695/5 "2023-09-12T06:44:27Z")

</div>

Hey ,  
Somebody please help me on this.

Regards,  
Heramb

---

<div class="post-metadata">

**Author:** ![Fin\_Ubels](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/fin_ubels/32/18008_2.png) [@Fin\_Ubels](https://community.dynatrace.com/u/Fin_Ubels)\
**Post date:** [September 21, 2023, 1:51am UTC](https://community.dynatrace.com/t/how-to-update-create-a-dashboard-using-document-service-of-dynatrace/40695/6 "2023-09-21T01:51:38Z")

</div>

Hey Heramb,

Hopefully you’ve already come across the solution. I was unable to find anything regarding that exact error or reproduce it but as for the optimisticLockingVersion field, if you first GET the document you’ll get a version returned. This is NOT the version in the document JSON but in it’s metadata. The optimisticLockingVersion field needs to be this latest version. Every time a document is updated, this version will update and to update it through the API you’ll need this latest version every time.

 ![Fin_Ubels_1-1695261037334.png](https://global.discourse-cdn.com/dynatrace/original/3X/8/8/8805e1c77663d618272252a196c939f443e6dd2f.png)

---

<div class="post-metadata">

**Author:** ![paolo\_fumanelli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/paolo_fumanelli/32/1037_2.png) [@paolo\_fumanelli](https://community.dynatrace.com/u/paolo_fumanelli)\
**Post date:** [January 29, 2025, 11:37am UTC](https://community.dynatrace.com/t/how-to-update-create-a-dashboard-using-document-service-of-dynatrace/40695/7 "2025-01-29T11:37:33Z")

</div>

Hi&nbsp;[@Fin\_Ubels](https://community.dynatrace.com/user/47376),&nbsp;[@heramb\_sawant](https://community.dynatrace.com/user/46340),&nbsp;I’m trying to do a similar thing. I want to automatically create a new tile and append it to an existing dashboard. Everything ok until I want to update the document with&nbsp; **updateDocumentContent** method, where I should attach the updated dashboard JSON in the body. The body is a&nbsp; **UpdateDocumentContentBody**.

[Document | Dynatrace Developer](https://developer.dynatrace.com/develop/sdks/client-document/#updatedocumentcontent)

```javascript
const data = await documentsClient.updateDocumentContent({
id: "...",
optimisticLockingVersion: "...",
body: { content: "..." },
});

```

How can I convert my updated JSON such that I can assign it to body.content correctly?

thanks  
Paolo
