Submit a Notebook Convert Command
- POST /api/v1.2/commands/
Use this API to submit a Notebook convert command to download or email notebooks and dashboards in PDF, PNG, and HTML formats.
Required Role
The following users can make this API call:
Users who belong to the system-user or system-admin group.
Users who belong to a group associated with a role that allows submitting a command. See Managing Groups and Managing Roles for more information.
Parameters
Note
Parameters marked in bold below are mandatory. Others are optional and have default values.
Parameters |
Description |
---|---|
command_type |
NotebookConvertCommand |
resourceId |
Id of the notebook or dashboard to be converted. |
resourceType |
|
fileFormat |
Format to which the notebook or dashboard has to be converted.
The supported values are |
showCode |
Specifies whether the notebook that is converted should contain the code. Possible values are
|
mailIds |
List of comma separated of email addresses to which converted notebook or dashboard has to be sent. Note This parameter is not required for downloading notebooks or dashboards. |
Examples
Example 1: Python API Framework
Notebook
The following sample code shows how to email a notebook as a PNG file.
import sys
import pycurl
import json
c= pycurl.Curl()
url="https://api.qubole.com/api/v1.2/commands"
auth_token = <provide auth token here>
c.setopt(pycurl.URL, url)
c.setopt(pycurl.HTTPHEADER, ["X-AUTH-TOKEN: "+ auth_token, "Content-Type:application/json", "Accept: application/json"])
c.setopt(pycurl.POST,1)
data=json.dumps({"resourceId":15, "resourceType":"Note", "fileFormat": "png","mailIds":"[email protected],[email protected]", "command_type":"NotebookConvertCommand"})
c.setopt(pycurl.POSTFIELDS, data)
c.perform()
The following sample code shows how to download a notebook as a PNG file.
import sys
import pycurl
import json
c= pycurl.Curl()
url="https://api.qubole.com/api/v1.2/commands"
auth_token = <provide auth token here>
c.setopt(pycurl.URL, url)
c.setopt(pycurl.HTTPHEADER, ["X-AUTH-TOKEN: "+ auth_token, "Content-Type:application/json", "Accept: application/json"])
c.setopt(pycurl.POST,1)
data=json.dumps({"resourceId":15, "resourceType": "Note","fileFormat": "png", "command_type":"NotebookConvertCommand"})
c.setopt(pycurl.POSTFIELDS, data)
c.perform()
Dashboard
The following sample code shows how to download a dashboard as a PNG file.
import sys
import pycurl
import json
c= pycurl.Curl()
url="https://api.qubole.com/api/v1.2/commands"
auth_token = <provide auth token here>
c.setopt(pycurl.URL, url)
c.setopt(pycurl.HTTPHEADER, ["X-AUTH-TOKEN: "+ auth_token, "Content-Type:application/json", "Accept: application/json"])
c.setopt(pycurl.POST,1)
data=json.dumps({"resourceId":15, "resourceType": "NotebookDashboard","fileFormat": "png", "command_type":"NotebookConvertCommand"})
c.setopt(pycurl.POSTFIELDS, data)
c.perform()
Example 2: Using Command Line Parameter
Notebook
The following cURL command shows how to email a notebook as a PNG file.
curl -i -X POST -H "X-AUTH-TOKEN: $AUTH_TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" \
-d '{"resourceId":"15", "resourceType":"Note", "fileFormat":"png", "command_type":"NotebookConvertCommand", "mailIds": "[email protected],[email protected]"}' \
"https://api.qubole.com/api/v1.2/commands"
The following cURL command shows how to convert a notebook as a PNG file with code
curl -i -X POST -H "X-AUTH-TOKEN: $AUTH_TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" \
-d '{"resourceId":"15", "resourceType": "Note", "fileFormat":"png", "command_type":"NotebookConvertCommand", "showCode": "true"}' \
"https://api.qubole.com/api/v1.2/commands"
The following cURL command shows how to download a notebook as a PNG file.
curl -i -X POST -H "X-AUTH-TOKEN: $AUTH_TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" \
-d '{"resourceId":"15", "resourceType":"Note", "fileFormat":"png", "command_type":"NotebookConvertCommand"}' \
"https://api.qubole.com/api/v1.2/commands"
Dashboard
The following cURL command shows how to download a dashboard as a PNG file.
curl -i -X POST -H "X-AUTH-TOKEN: $AUTH_TOKEN" -H "Content-Type: application/json" -H "Accept: application/json" \
-d '{"resourceId":"15", "resourceType": "NotebookDashboard", "fileFormat":"png", "command_type":"NotebookConvertCommand"}' \
"https://api.qubole.com/api/v1.2/commands"
See View Command Status to check the status of the NotebookConvertCommand
command and Example to download the results file from the notebook/dashboard convert command to download the converted files.