<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how can i export my dashboard en format html using databriks api in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-can-i-export-my-dashboard-en-format-html-using-databriks-api/m-p/12112#M6971</link>
    <description>&lt;P&gt;@mathild noun​&amp;nbsp;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import databricks.workspace as workspace_api
import requests
&amp;nbsp;
# set up your Databricks workspace credentials
domain = "&amp;lt;your Databricks workspace domain&amp;gt;"
token = "&amp;lt;your Databricks API token&amp;gt;"
&amp;nbsp;
# set up the workspace client
workspace = workspace_api.WorkspaceApi(domain, token)
&amp;nbsp;
# set up the dashboard path and file name
dashboard_path = "/Shared/MyDashboard"
dashboard_file_name = "MyDashboard.html"
&amp;nbsp;
# export the dashboard
dashboard_html = workspace.export_dashboard(dashboard_path)
&amp;nbsp;
# write the dashboard HTML to a file
with open(dashboard_file_name, "w") as f:
    f.write(dashboard_html)
&amp;nbsp;
# load the HTML file into a requests object
with open(dashboard_file_name, "rb") as f:
    file_content = f.read()
html_file = {'file': ('MyDashboard.html', file_content)}
&amp;nbsp;
# set up the email parameters
to = ['team1@example.com', 'team2@example.com']
subject = 'My Dashboard'
body = 'Please find attached my dashboard.'
&amp;nbsp;
# send the email with the dashboard HTML attachment
response = requests.post(
    "https://api.mailgun.net/v3/&amp;lt;your-mailgun-domain&amp;gt;/messages",
    auth=("api", "&amp;lt;your-mailgun-api-key&amp;gt;"),
    files=[html_file],
    data={"from": "&amp;lt;your-email-address&amp;gt;",
          "to": to,
          "subject": subject,
          "html": body})&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In this example, we first use the  export_dashboard() function to export the dashboard HTML to a file, then we load the HTML file into a requests object and send it as an email attachment using Mailgun's email API. Note that you'll need to replace the placeholders in the code (such as  &amp;lt;your Databricks workspace domain&amp;gt;, &amp;lt;your Databricks API token&amp;gt;, &amp;lt;your-mailgun-domain&amp;gt;, &amp;lt;your-mailgun-api-key&amp;gt;, &lt;/P&gt;&lt;P&gt;&amp;lt;your-email-address&amp;gt;, etc.) with your own values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Mar 2023 04:20:36 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2023-03-09T04:20:36Z</dc:date>
    <item>
      <title>how can i export my dashboard en format html using databriks api</title>
      <link>https://community.databricks.com/t5/data-engineering/how-can-i-export-my-dashboard-en-format-html-using-databriks-api/m-p/12111#M6970</link>
      <description>&lt;P&gt;hi everyone, i would like to export my dashbord in html format and embed it in my body of my email in order to send it to my team&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so there is my code python for the databriks api &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Capture"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/851iF35D2D8515EE4EDD/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture" alt="Capture" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and i got this error &lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Capture1"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/842iB48DFB7C491F846C/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture1" alt="Capture1" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and when i put my htm in the body of my message i got nothing on the result&lt;/P&gt;&lt;P&gt;so there is my code for sending emails  &lt;span class="lia-inline-image-display-wrapper" image-alt="Capture3"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/839i269FA25D5C763A0B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture3" alt="Capture3" /&gt;&lt;/span&gt;thank you for your responses &lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2023 11:08:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-can-i-export-my-dashboard-en-format-html-using-databriks-api/m-p/12111#M6970</guid>
      <dc:creator>nounou</dc:creator>
      <dc:date>2023-01-13T11:08:07Z</dc:date>
    </item>
    <item>
      <title>Re: how can i export my dashboard en format html using databriks api</title>
      <link>https://community.databricks.com/t5/data-engineering/how-can-i-export-my-dashboard-en-format-html-using-databriks-api/m-p/12112#M6971</link>
      <description>&lt;P&gt;@mathild noun​&amp;nbsp;:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;import databricks.workspace as workspace_api
import requests
&amp;nbsp;
# set up your Databricks workspace credentials
domain = "&amp;lt;your Databricks workspace domain&amp;gt;"
token = "&amp;lt;your Databricks API token&amp;gt;"
&amp;nbsp;
# set up the workspace client
workspace = workspace_api.WorkspaceApi(domain, token)
&amp;nbsp;
# set up the dashboard path and file name
dashboard_path = "/Shared/MyDashboard"
dashboard_file_name = "MyDashboard.html"
&amp;nbsp;
# export the dashboard
dashboard_html = workspace.export_dashboard(dashboard_path)
&amp;nbsp;
# write the dashboard HTML to a file
with open(dashboard_file_name, "w") as f:
    f.write(dashboard_html)
&amp;nbsp;
# load the HTML file into a requests object
with open(dashboard_file_name, "rb") as f:
    file_content = f.read()
html_file = {'file': ('MyDashboard.html', file_content)}
&amp;nbsp;
# set up the email parameters
to = ['team1@example.com', 'team2@example.com']
subject = 'My Dashboard'
body = 'Please find attached my dashboard.'
&amp;nbsp;
# send the email with the dashboard HTML attachment
response = requests.post(
    "https://api.mailgun.net/v3/&amp;lt;your-mailgun-domain&amp;gt;/messages",
    auth=("api", "&amp;lt;your-mailgun-api-key&amp;gt;"),
    files=[html_file],
    data={"from": "&amp;lt;your-email-address&amp;gt;",
          "to": to,
          "subject": subject,
          "html": body})&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In this example, we first use the  export_dashboard() function to export the dashboard HTML to a file, then we load the HTML file into a requests object and send it as an email attachment using Mailgun's email API. Note that you'll need to replace the placeholders in the code (such as  &amp;lt;your Databricks workspace domain&amp;gt;, &amp;lt;your Databricks API token&amp;gt;, &amp;lt;your-mailgun-domain&amp;gt;, &amp;lt;your-mailgun-api-key&amp;gt;, &lt;/P&gt;&lt;P&gt;&amp;lt;your-email-address&amp;gt;, etc.) with your own values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this helps! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 04:20:36 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-can-i-export-my-dashboard-en-format-html-using-databriks-api/m-p/12112#M6971</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-03-09T04:20:36Z</dc:date>
    </item>
  </channel>
</rss>

